Language: accept untyped global constant definitions - #547
Conversation
chqrlie
commented
Jul 25, 2026
- type is inferred from init value
- cannot take the address of an untyped global constant
- add tests
- need bootstrap to use in the compiler or libraries
94620a4 to
39b7c01
Compare
|
I'm playing around with this. I think we can tighten some checks: Maybe we can also enforce local const to be Capital cased (perhaps only for untypes at first? to make it easier) Code-wise there seems to be some duplication between analyseGlobalVarDecl and analyseDecl, maybe we can refactor that into a common function? The error messages contain 'untyped global constant'. I think this tshould be 'untyped constant' since it should also apply to local constants. |
39b7c01 to
bec19b1
Compare
Forbidding pointer arithmetics would be consistent with the rejection of the
I would not do that, local variables are not global constants, defining them as There is a fundamental semantical difference between global constants that name concepts that are given for the whole program or system interface and
Yes, I shall look into that, but for a separate PR
Indeed, it should not mention |
bec19b1 to
208168f
Compare
* type is inferred from init value
* accept `const` blocks: `const { ONE = 1, TWO = 2 }`
* cannot take the address of an untyped global constant
* add tests
* need bootstrap to use in the compiler or libraries
208168f to
2af17be
Compare