elikaski / BF-it

A C-like language to Brainfuck compiler, written in Python
MIT License
120 stars 11 forks source link

False warning in uninitialized variable in for loops #62

Closed elikaski closed 3 years ago

elikaski commented 3 years ago

It is possible to declare an array in a for loop statement E.g.

    i = 0;
    for (int arr[10]; i < 10; i++) {
        ...
    }

An example is available in loops.code And even declare and initialize: for (int arr[10] = {1,2,3,4} ; i < 10; i++) {

These kind of for loops cause a "false" warning to printed: [Warning] For loop variable 'ID arr (line 6 column 14)' isn't assigned to anything and may cause side effects

elikaski commented 3 years ago

@NeeEoo can't assign you 🤷

NeeEoo commented 3 years ago

Ok you can now assign me. I have to interact with the conversation at least once for you to be able.

I'm gonna change get_token_after_array_access to add the offset parameter from the structs branch. Since it expects an id before LBRACK, and i can't move the token_pointer