View Issue Details

IDProjectCategoryView StatusLast Update
0038097FPCCompilerpublic2020-11-17 15:32
ReporterAlfred Assigned ToMichael Van Canneyt  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Summary0038097: Using a constant char array in a case statement gives error.
Descriptionprogram case_error;

type
  TDischargeType = (dtResistor, dtCurrent, dtPower, dtUnknown);

const
  TDischargeTypeUnit: array[TDischargeType] of Char = ('R','I','P','X');

var
  aChar:char;
begin
  aChar:='R';
  case aChar of
    TDischargeTypeUnit[TDischargeType.dtResistor]: writeln('I am ok');
  end;
end.

case_error.lpr(14,50) Error: Constant Expression expected
Additional InformationCould be related:
https://bugs.freepascal.org/view.php?id=34091
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget-
Attached Files

Activities

Michael Van Canneyt

2020-11-17 15:31

administrator   ~0127004

Last edited: 2020-11-17 15:32

View 2 revisions

This is normal, same as in Delphi.
[DCC Error] Project5.dpr(21): E2026 Constant expression expected

(array access is never a constant)

Issue History

Date Modified Username Field Change
2020-11-17 15:16 Alfred New Issue
2020-11-17 15:31 Michael Van Canneyt Assigned To => Michael Van Canneyt
2020-11-17 15:31 Michael Van Canneyt Status new => resolved
2020-11-17 15:31 Michael Van Canneyt Resolution open => no change required
2020-11-17 15:31 Michael Van Canneyt FPCTarget => -
2020-11-17 15:31 Michael Van Canneyt Note Added: 0127004
2020-11-17 15:32 Michael Van Canneyt Note Edited: 0127004 View Revisions