The debugger can modify unaliased consts

NEW
Unassigned

Status

()

4 years ago
2 years ago

People

(Reporter: jandem, Unassigned)

Tracking

(Blocks: 1 bug)

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

4 years ago
We fail the testcase below because setVariable sets the const's value to 3.

However, if the const is aliased (just add a debugger-statement or a lambda that uses 'x'), the debugger is no longer able to modify it and it throws TypeError: "x" is read-only.

var g = newGlobal();
g.parent = this;
g.eval("(" + function() {
    var dbg = new Debugger(parent);
    dbg.onEnterFrame = function(frame) {
	frame.onStep = function() {
	    if (frame.environment.getVariable("x") === 2)
		frame.environment.setVariable("x", 3);
	}
    };
} + ")()");
function f() {
    const x = 2;
    assertEq(x, 2);
}
f();
(Reporter)

Updated

4 years ago
Blocks: 1077945
Is this maybe fixed by the frontend rewrite?
Flags: needinfo?(shu)
Apparently not :/
> Assertion failed: got 3, expected 2

Comment 3

2 years ago
This should be consistent, either both frame and env bindings can be modified or neither can be. But I'm still unclear if this should be allowed or disallowed. I'll chat with jimb.
Flags: needinfo?(shu)
You need to log in before you can comment on or make changes to this bug.