c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

Constant expressions fail in types on global level #99

Closed lerno closed 4 years ago

lerno commented 5 years ago
module test;

const i32 FOO = 2;
type Foo i32[FOO + 1];

public func i32 main(i32 argc, i8*[] argv)  { return 0; }

This construct causes a crash.

bvdberg commented 5 years ago

Parsing + Analysing seems fine on master. C-code generation crashes indeed. Constant folding would help here, since then we can just generate the numbers and then we don't have to track the ordering of all the defines..

lerno commented 5 years ago

Exactly, constant folding needs to be a priority moving further along. When doing constant folding it's also important to open up for macros, since macros are evaluated at the same time. For example this should be valid:

type Foo i32[@macro_something()]

bvdberg commented 5 years ago

Ik was playing around with some macro options, but having non-textual macros does open up a Lot of questions. I'll open a separate issue for those discussions on the forum in this topic.

bvdberg commented 4 years ago

fixed