Skip to content

Variable scope issue #91

@kLabz

Description

@kLabz

When using if without brackets, the scope stays the same and variables can be shadowed:

var expr = '
	var a = "test";
	if (true) var a = 42;
	return a;
';

var parser = new hscript.Parser();
var ast = parser.parseString(expr);
var interp = new hscript.Interp();
trace(interp.execute(ast)); // 42

Works as expected when using brackets.

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