Skip to content

mutable variables are not considered local, thus cannot be evaluated in conditionals #154

@nohehf

Description

@nohehf

The following tsg stanza, while executed on an empty python file:

(module) {
    var a = #true
    if a {
        print "a is true"
    }
}

Will error:

Expected local value at (6, 8)
test.tsg:6:8:
6 |     if a {
  |        ^

Where it would work just fine with an immutable "let":

(module) {
    let a = #true
    if a {
        print "a is true"
    }
}

Will print "a is true" as expected.

This is a weird behavior, as a should have the same scope in both cases. It also prevents to do patterns such as:

var a = ; some expression that might be null
if (is-null a) {
    set a = ; some default value
}

Additionally I think that it is quite limiting not being able to execute conditionals on non-local values, why is that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions