Skip to content

Type checker implements flow-sensitive typing #100

Description

@vishnu-m77

The current type checker (analog or atomic) allows reassignment of a variable to a different type in the same scope. This behavior is described as flow-sensitive typing. Consider the following code:

r = true
if (r) {
r = 5
}
r = r + 2

This will raise a type error on the last line, as r is a bool in the global scope, and an int only in the local scope of the if statement block. The code below however:

r = true
r = 5
r = r + 2

will not raise a type error, as the variable r takes on the type of its latest declaration, which is int. Future development can involve SSA and other optimizations which will substitute the current behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    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