JS: Parser: Never run in strict mode

This initial change is a bit of a hacky way to achieve our goals (since
it doesn't rewrite all the uses of this.strict), but it is easy to
understand is correct. Let's accept test changes NOW, and ensure that
later changes don't change things further.
This commit is contained in:
Rasmus Wriedt Larsen
2024-04-09 14:37:07 +02:00
parent 7b2dc325ec
commit 1985dd629d

View File

@@ -244,7 +244,13 @@ public class Parser {
this.exprAllowed = true;
// Figure out if it's a module code.
this.strict = this.inModule = options.sourceType().equals("module");
this.inModule = options.sourceType().equals("module");
// We don't care to report syntax errors in code that might be using strict mode. In
// the end, we don't know whether that code is put through additional build steps
// causing our alleged syntax errors to disappear. Therefore, we hardcode
// this.strict to false.
this.strict = false;
// Used to signify the start of a potential arrow function
this.potentialArrowAt = -1;
@@ -323,18 +329,13 @@ public class Parser {
this.nextToken();
}
// Toggle strict mode. Re-reads the next number or string to please
// pedantic tests (`"use strict"; 010;` should fail).
// DEPRECATED. When we respected strict mode, this method was used to toggle strict
// mode (and would re-read the next number or string to please pedantic tests (`"use
// strict"; 010;` should fail)).
public void setStrict(boolean strict) {
this.strict = strict;
if (this.type != TokenType.num && this.type != TokenType.string) return;
this.pos = this.start;
while (this.pos < this.lineStart) {
this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
--this.curLine;
}
this.nextToken();
// always false
return;
}
public TokContext curContext() {