Skip to content

Data space scoping #22

@Aaron3154518

Description

@Aaron3154518

Not sure if this is an issue or not:

Different scopes can have two distinct variables (data spaces) with the same name. However all data spaces in the Computation class are given the same scope. This creates two distinct data spaces which are treated as one due to having the same name. We need to produce two differently named data spaces.
We can implement this using a static integer counter. Every time we hit a redeclared variable in a new scope, rename it and every use of it within that current scope to var__v{counter}.

Example:

int foo = 0;
if (condition) { int foo = 1; } // different scope is not recognized in Computation
print (foo); // Should be 0, not 1.

Would become:

int foo = 0;
if (condition) { int foo__v1 = 1; } // different scope is not recognized, but variable is renamed so it's all good
print(foo);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions