← board

Char literal in a constant expression: ConstEval rejected 'a'

Problem

ConstEval (parser.inc) handled integer / boolean / Ord-style ordinals but not a character literal. A single-quoted 'a' lexes as tkString (token Kind 3) of length 1, which fell through to no primary alternative:

const W: array[1..3] of Char = ('a','b','c');
pascal26: Expected: ), but got: a (Kind: 3)
pascal26: error: unexpected token ()

Reproduced on a plain global typed const, so not specific to the local-const work — any const-expression position wanting a char value hit it.

Fix

In ConstEval, add a primary alternative: a length-1 tkString evaluates to its character code (Ord(SVal[1])). Compile-time only; no codegen change.

Acceptance

Log