Skip to content

Commit 1985dd6

Browse files
committed
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.
1 parent 7b2dc32 commit 1985dd6

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

javascript/extractor/src/com/semmle/jcorn/Parser.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,13 @@ public Parser(Options options, String input, int startPos) {
244244
this.exprAllowed = true;
245245

246246
// Figure out if it's a module code.
247-
this.strict = this.inModule = options.sourceType().equals("module");
247+
this.inModule = options.sourceType().equals("module");
248+
249+
// We don't care to report syntax errors in code that might be using strict mode. In
250+
// the end, we don't know whether that code is put through additional build steps
251+
// causing our alleged syntax errors to disappear. Therefore, we hardcode
252+
// this.strict to false.
253+
this.strict = false;
248254

249255
// Used to signify the start of a potential arrow function
250256
this.potentialArrowAt = -1;
@@ -323,18 +329,13 @@ protected void next() {
323329
this.nextToken();
324330
}
325331

326-
// Toggle strict mode. Re-reads the next number or string to please
327-
// pedantic tests (`"use strict"; 010;` should fail).
332+
// DEPRECATED. When we respected strict mode, this method was used to toggle strict
333+
// mode (and would re-read the next number or string to please pedantic tests (`"use
334+
// strict"; 010;` should fail)).
328335

329336
public void setStrict(boolean strict) {
330-
this.strict = strict;
331-
if (this.type != TokenType.num && this.type != TokenType.string) return;
332-
this.pos = this.start;
333-
while (this.pos < this.lineStart) {
334-
this.lineStart = this.input.lastIndexOf("\n", this.lineStart - 2) + 1;
335-
--this.curLine;
336-
}
337-
this.nextToken();
337+
// always false
338+
return;
338339
}
339340

340341
public TokContext curContext() {

0 commit comments

Comments
 (0)