Merge branch 'main' into js-extractor-fix

This commit is contained in:
Asger F
2024-04-17 20:55:54 +02:00
committed by GitHub
2461 changed files with 97497 additions and 291292 deletions

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() {
@@ -3107,7 +3108,7 @@ public class Parser {
if (stmt != null) body.add(stmt);
if (first && allowStrict && this.isUseStrict(stmt)) {
oldStrict = this.strict;
this.setStrict(this.strict = true);
this.setStrict(true);
}
first = false;
}

View File

@@ -41,7 +41,7 @@ public class Main {
* A version identifier that should be updated every time the extractor changes in such a way that
* it may produce different tuples for the same file under the same {@link ExtractorConfig}.
*/
public static final String EXTRACTOR_VERSION = "2023-10-13";
public static final String EXTRACTOR_VERSION = "2024-04-17";
public static final Pattern NEWLINE = Pattern.compile("\n");

View File

@@ -196,29 +196,5 @@ successor(#20045,#20048)
successor(#20057,#20041)
successor(#20038,#20037)
successor(#20054,#20038)
#20059=*
js_parse_errors(#20059,#20001,"Error: Assigning to arguments in strict mode"," arguments = 42;
")
#20060=@"loc,{#10000},3,3,3,3"
locations_default(#20060,#10000,3,3,3,3)
hasLocation(#20059,#20060)
#20061=*
lines(#20061,#20001,"function f() {","
")
hasLocation(#20061,#20003)
#20062=*
lines(#20062,#20001," 'use strict';","
")
hasLocation(#20062,#20005)
indentation(#10000,2," ",2)
#20063=*
lines(#20063,#20001," arguments = 42;","
")
hasLocation(#20063,#20007)
indentation(#10000,3," ",2)
#20064=*
lines(#20064,#20001,"}","")
hasLocation(#20064,#20009)
numlines(#20001,4,0,0)
numlines(#10000,4,4,0)
filetype(#10000,"javascript")