Skip to content

Constants declared within a function reside in global scope #352

Description

@cardillan

Constants declared in functions actually reside in global scope:

def foo()
    const i = 1;
    print(i);
end;

foo();
i = 2;

produces an error: Assignment to constant or parameter 'i' not allowed..

Originally, constants weren't meant to be created in functions, but with a planned addition of const function parameters of inline functions, it does make sense to allow that. The bug will be fixed by creating the constants properly in the local scope.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerRelated to the code generator

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions