Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Params initialized with params leads to an error in generated code #13

Open
schorg opened this issue Jan 28, 2023 · 0 comments
Open

Params initialized with params leads to an error in generated code #13

schorg opened this issue Jan 28, 2023 · 0 comments

Comments

@schorg
Copy link
Member

schorg commented Jan 28, 2023

If you try to initialize a param with another param the type-checker does not complain.
But, the generated code cannot be compiled by a C-compiler

To Reproduce
The following program in file typing.blc

param x: int32 = 42

param y: int32 = x * 2

@[EntryPoint]
activity Test() returns int32
    await true
    return y
end

compiles without errors

blechc --app  typing.blc

A C compiler cannot compile the generated code

cd blech
clang -Iinclude blech.c

and shows the following error message

In file included from blech.c:21:
./typing.c:42:54: error: initializer element is not a compile-time constant
static blc_int32 blc_01typing01_y = blc_01typing01_x * 2;
                                    ~~~~~~~~~~~~~~~~~^~~
1 error generated.

Expected behaviour
Either a typing error in the Blech compiler,
Or even better - but much more effort and a big change - a different code generation for parameter initialization, maybe as a function, called from the initialiser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant