fix(0113): negated-literal global initializers fold as constants
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.
This commit is contained in:
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-1 -4 -128
|
||||
Reference in New Issue
Block a user