globalInitValue had no unary_op arm, so g : s64 = -1; fell into the catch-all 'must be initialized by a compile-time constant' even though constExprValue already folds negate(literal) for the module-const identifier route. The new arm routes through constExprValue and applies the direct-literal rules to the folded value: checkIntLiteralFits on ints (g : s8 = -300 gets the range diagnostic), and a negated float at an integer global narrows only when integral (-4.0 folds to -4, -4.5 errors). Binary-op initializers keep the specific non-constant diagnostic. Regression: examples/0175-types-negative-literal-global.sx.
2 lines
1 B
Plaintext
2 lines
1 B
Plaintext
|