Changeset 288473 in webkit


Ignore:
Timestamp:
Jan 24, 2022 2:51:13 PM (6 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Support import assertion syntax
https://bugs.webkit.org/show_bug.cgi?id=235312

Reviewed by Ross Kirsling.

JSTests:

  • modules/import-meta-syntax.js:

(shouldThrow):

  • stress/import-syntax.js:
  • stress/modules-syntax-error.js:
  • stress/modules-syntax-import-assertion-error.js: Added.

(shouldThrow):

  • stress/modules-syntax-import-assertion.js: Added.

LayoutTests/imported/w3c:

  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
  • web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
  • web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt:
  • web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt:
  • web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt:

Source/JavaScriptCore:

This patch adds syntax support for import assertion[1].
This does not add the actual feature propagating import assertion
to the module request yet.

[1]: https://github.com/tc39/proposal-import-assertions

  • bytecompiler/NodesCodegen.cpp:

(JSC::ImportNode::emitBytecode):

  • parser/ASTBuilder.h:

(JSC::ASTBuilder::createImportExpr):
(JSC::ASTBuilder::createImportAssertionList):
(JSC::ASTBuilder::appendImportAssertion):
(JSC::ASTBuilder::createImportDeclaration):
(JSC::ASTBuilder::createExportAllDeclaration):
(JSC::ASTBuilder::createExportNamedDeclaration):

  • parser/NodeConstructors.h:

(JSC::ImportNode::ImportNode):
(JSC::ImportDeclarationNode::ImportDeclarationNode):
(JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
(JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):

  • parser/Nodes.h:
  • parser/Parser.cpp:

(JSC::Parser<LexerType>::parseImportAssertions):
(JSC::Parser<LexerType>::parseImportDeclaration):
(JSC::Parser<LexerType>::parseExportDeclaration):
(JSC::Parser<LexerType>::parseMemberExpression):

  • parser/Parser.h:
  • parser/SyntaxChecker.h:

(JSC::SyntaxChecker::createImportExpr):
(JSC::SyntaxChecker::createImportAssertionList):
(JSC::SyntaxChecker::appendImportAssertion):
(JSC::SyntaxChecker::createImportDeclaration):
(JSC::SyntaxChecker::createExportAllDeclaration):
(JSC::SyntaxChecker::createExportNamedDeclaration):

  • runtime/JSGlobalObjectFunctions.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • runtime/OptionsList.h:
Location:
trunk
Files:
2 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r288411 r288473  
     12022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Support import assertion syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=235312
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * modules/import-meta-syntax.js:
     9        (shouldThrow):
     10        * stress/import-syntax.js:
     11        * stress/modules-syntax-error.js:
     12        * stress/modules-syntax-import-assertion-error.js: Added.
     13        (shouldThrow):
     14        * stress/modules-syntax-import-assertion.js: Added.
     15
    1162022-01-21  Yusuke Suzuki  <ysuzuki@apple.com>
    217
  • trunk/JSTests/modules/import-meta-syntax.js

    r284435 r288473  
    1515shouldThrow(() => {
    1616    checkModuleSyntax(`(import["Cocoa"])`);
    17 }, `SyntaxError: Unexpected token '['. import call expects exactly one argument.:1`);
     17}, `SyntaxError: Unexpected token '['. import call expects one or two arguments.:1`);
    1818
    1919shouldThrow(() => {
  • trunk/JSTests/stress/import-syntax.js

    r284435 r288473  
    2828}
    2929
    30 testSyntaxError(`import)`, `SyntaxError: Unexpected token ')'. import call expects exactly one argument.`);
     30testSyntaxError(`import)`, `SyntaxError: Unexpected token ')'. import call expects one or two arguments.`);
    3131testSyntaxError(`new import(`, `SyntaxError: Cannot use new with import.`);
    3232testSyntaxError(`import.hello()`, `SyntaxError: Unexpected identifier 'hello'. "import." can only be followed with meta.`);
    33 testSyntaxError(`import[`, `SyntaxError: Unexpected token '['. import call expects exactly one argument.`);
    34 testSyntaxError(`import<`, `SyntaxError: Unexpected token '<'. import call expects exactly one argument.`);
     33testSyntaxError(`import[`, `SyntaxError: Unexpected token '['. import call expects one or two arguments.`);
     34testSyntaxError(`import<`, `SyntaxError: Unexpected token '<'. import call expects one or two arguments.`);
    3535
    3636testSyntaxError(`import()`, `SyntaxError: Unexpected token ')'`);
    37 testSyntaxError(`import(a, b)`, `SyntaxError: Unexpected token ','. import call expects exactly one argument.`);
    38 testSyntaxError(`import(a, b, c)`, `SyntaxError: Unexpected token ','. import call expects exactly one argument.`);
     37testSyntaxError(`import(a, b, c)`, `SyntaxError: Unexpected identifier 'c'. import call expects one or two arguments.`);
    3938testSyntaxError(`import(...a)`, `SyntaxError: Unexpected token '...'`);
    4039testSyntaxError(`import(,a)`, `SyntaxError: Unexpected token ','`);
    4140testSyntaxError(`import(,)`, `SyntaxError: Unexpected token ','`);
    42 testSyntaxError(`import("Hello";`, `SyntaxError: Unexpected token ';'. import call expects exactly one argument.`);
    43 testSyntaxError(`import("Hello"];`, `SyntaxError: Unexpected token ']'. import call expects exactly one argument.`);
    44 testSyntaxError(`import("Hello",;`, `SyntaxError: Unexpected token ','. import call expects exactly one argument.`);
    45 testSyntaxError(`import("Hello", "Hello2";`, `SyntaxError: Unexpected token ','. import call expects exactly one argument.`);
     41testSyntaxError(`import("Hello";`, `SyntaxError: Unexpected token ';'. import call expects one or two arguments.`);
     42testSyntaxError(`import("Hello"];`, `SyntaxError: Unexpected token ']'. import call expects one or two arguments.`);
     43testSyntaxError(`import("Hello",;`, `SyntaxError: Unexpected token ';'`);
     44testSyntaxError(`import("Hello", "Hello2";`, `SyntaxError: Unexpected token ';'. import call expects one or two arguments.`);
    4645
    4746
    48 testSyntaxError(`import = 42`, `SyntaxError: Unexpected token '='. import call expects exactly one argument.`);
    49 testSyntaxError(`[import] = 42`, `SyntaxError: Unexpected token ']'. import call expects exactly one argument.`);
    50 testSyntaxError(`{import} = 42`, `SyntaxError: Unexpected token '}'. import call expects exactly one argument.`);
     47testSyntaxError(`import = 42`, `SyntaxError: Unexpected token '='. import call expects one or two arguments.`);
     48testSyntaxError(`[import] = 42`, `SyntaxError: Unexpected token ']'. import call expects one or two arguments.`);
     49testSyntaxError(`{import} = 42`, `SyntaxError: Unexpected token '}'. import call expects one or two arguments.`);
    5150testSyntaxError(`let import = 42`, `SyntaxError: Unexpected keyword 'import'`);
    5251testSyntaxError(`var import = 42`, `SyntaxError: Cannot use the keyword 'import' as a variable name.`);
  • trunk/JSTests/stress/modules-syntax-error.js

    r270923 r288473  
    108108    import * as from from "Cocoa"
    109109}
    110 `, `SyntaxError: Unexpected token '*'. import call expects exactly one argument.:3`);
     110`, `SyntaxError: Unexpected token '*'. import call expects one or two arguments.:3`);
    111111
    112112checkModuleSyntaxError(String.raw`
     
    114114    import * as from from "Cocoa"
    115115}
    116 `, `SyntaxError: Unexpected token '*'. import call expects exactly one argument.:3`);
     116`, `SyntaxError: Unexpected token '*'. import call expects one or two arguments.:3`);
    117117
    118118checkModuleSyntaxError(String.raw`
     
    120120    import * as from from "Cocoa"
    121121}
    122 `, `SyntaxError: Unexpected token '*'. import call expects exactly one argument.:3`);
     122`, `SyntaxError: Unexpected token '*'. import call expects one or two arguments.:3`);
    123123
    124124checkModuleSyntaxError(String.raw`
     
    126126    import * as from from "Cocoa"
    127127}
    128 `, `SyntaxError: Unexpected token '*'. import call expects exactly one argument.:3`);
     128`, `SyntaxError: Unexpected token '*'. import call expects one or two arguments.:3`);
    129129
    130130checkModuleSyntaxError(String.raw`
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r288465 r288473  
     12022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Support import assertion syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=235312
     5
     6        Reviewed by Ross Kirsling.
     7
     8        * web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt:
     9        * web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt:
     10        * web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt:
     11        * web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt:
     12        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt:
     13        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt:
     14        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt:
     15        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt:
     16        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt:
     17        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt:
     18        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt:
     19        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt:
     20        * web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt:
     21        * web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt:
     22        * web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt:
     23        * web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt:
     24
    1252022-01-24  Antti Koivisto  <antti@apple.com>
    226
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/css-module-worker-test-expected.txt

    r267646 r288473  
    11
    2 PASS A static import CSS Module within a web worker should not load.
    3 PASS A dynamic import CSS Module within a web worker should not load.
    4 PASS A CSS Module within a web worker should not load.
     2PASS A static import CSS Module within a web worker should not load and should not attempt to fetch the module.
     3FAIL A dynamic import CSS Module within a web worker should not load and should not attempt to fetch the module. assert_equals: Shouldn't have tried fetching CSS module in worker expected 0 but got 1
     4PASS An attempt to load a CSS module as a worker should fail.
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-dynamic-expected.txt

    r279427 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL Load a CSS module with dynamic import() promise_test: Unhandled rejection with value: object "TypeError: 'text/css' is not a valid JavaScript MIME type."
     3PASS Ensure that loading a CSS module with dymnamic import() fails without a type assertion
    44
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any-expected.txt

    r279427 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2PASS Dynamic import with an empty assert clause should succeed
     3PASS Dynamic import with an unsupported import assertion should succeed
     4FAIL Dynamic import with an unsupported type assertion should fail assert_unreached: Should have rejected: Dynamic import with an unsupported type assertion should fail Reached unreachable code
    45
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/import-assertions/dynamic-import-with-assertion-argument.any.worker-expected.txt

    r279427 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2PASS Dynamic import with an empty assert clause should succeed
     3PASS Dynamic import with an unsupported import assertion should succeed
     4FAIL Dynamic import with an unsupported type assertion should fail assert_unreached: Should have rejected: Dynamic import with an unsupported type assertion should fail Reached unreachable code
    45
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL UTF-8 BOM should be stripped when decoding JSON module script promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL UTF-16BE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16BE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
     4    [native code]
     5}" ("SyntaxError")
     6FAIL UTF-16LE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16LE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
     7    [native code]
     8}" ("SyntaxError")
    49
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/charset-bom.any.worker-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL UTF-8 BOM should be stripped when decoding JSON module script promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL UTF-16BE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16BE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
     4    [native code]
     5}" ("SyntaxError")
     6FAIL UTF-16LE BOM should result in parse error in JSON module script promise_rejects_js: Expected parse error from UTF-16LE BOM function "function () { throw e }" threw object "TypeError: 'application/json' is not a valid JavaScript MIME type." ("TypeError") expected instance of function "function SyntaxError() {
     7    [native code]
     8}" ("SyntaxError")
    49
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2PASS Try importing JSON module with MIME type application/json+protobuf
     3PASS Try importing JSON module with MIME type application/json+blah
     4PASS Try importing JSON module with MIME type text/x-json
     5PASS Try importing JSON module with MIME type text/json+blah
     6PASS Try importing JSON module with MIME type application/blahjson
     7PASS Try importing JSON module with MIME type image/json
    48
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/invalid-content-type.any.worker-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2PASS Try importing JSON module with MIME type application/json+protobuf
     3PASS Try importing JSON module with MIME type application/json+blah
     4PASS Try importing JSON module with MIME type text/x-json
     5PASS Try importing JSON module with MIME type text/json+blah
     6PASS Try importing JSON module with MIME type application/blahjson
     7PASS Try importing JSON module with MIME type image/json
    48
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/json-module-service-worker-test.https-expected.txt

    r285346 r288473  
    22FAIL Javascript importing JSON Module should load within the context of a service worker promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected identifier 'assert'. Expected a ';' following a targeted import declaration."
    33PASS Trying to register a service worker with a top-level JSON Module should fail
    4 FAIL JSON Module dynamic import should not load within the context of a service worker promise_test: Unhandled rejection with value: object "TypeError: SyntaxError: Unexpected token ','. import call expects exactly one argument."
     4PASS JSON Module dynamic import should not load within the context of a service worker
    55
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL Non-object: null promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL Non-object: true promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     4FAIL Non-object: false promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     5FAIL Non-object: string promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     6FAIL Non-object: array promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
    47
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/non-object.any.worker-expected.txt

    r285346 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL Non-object: null promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL Non-object: true promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     4FAIL Non-object: false promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     5FAIL Non-object: string promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     6FAIL Non-object: array promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
    47
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any-expected.txt

    r279427 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL Importing a specifier that previously failed due to an incorrect type assertion can succeed if the correct assertion is later given promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL Importing a specifier that previously succeeded with the correct type assertion should fail if the incorrect assertion is later given promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     4FAIL Two modules of different type with the same specifier can load if the server changes its responses promise_test: Unhandled rejection with value: object "TypeError: 'text/json' is not a valid JavaScript MIME type."
     5FAIL An import should always fail if the same specifier/type assertion pair failed previously assert_unreached: Should have rejected: import should always fail if the same specifier/type assertion pair failed previously Reached unreachable code
     6FAIL If an import previously succeeded for a given specifier/type assertion pair, future uses of that pair should yield the same result promise_test: Unhandled rejection with value: object "TypeError: 'text/json' is not a valid JavaScript MIME type."
    47
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/json-module/repeated-imports.any.worker-expected.txt

    r279427 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected token ','. import call expects exactly one argument.
    21
    3 Harness Error (FAIL), message = SyntaxError: Unexpected token ','. import call expects exactly one argument.
     2FAIL Importing a specifier that previously failed due to an incorrect type assertion can succeed if the correct assertion is later given promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     3FAIL Importing a specifier that previously succeeded with the correct type assertion should fail if the incorrect assertion is later given promise_test: Unhandled rejection with value: object "TypeError: 'application/json' is not a valid JavaScript MIME type."
     4FAIL Two modules of different type with the same specifier can load if the server changes its responses promise_test: Unhandled rejection with value: object "TypeError: 'text/json' is not a valid JavaScript MIME type."
     5FAIL An import should always fail if the same specifier/type assertion pair failed previously assert_unreached: Should have rejected: import should always fail if the same specifier/type assertion pair failed previously Reached unreachable code
     6FAIL If an import previously succeeded for a given specifier/type assertion pair, future uses of that pair should yield the same result promise_test: Unhandled rejection with value: object "TypeError: 'text/json' is not a valid JavaScript MIME type."
    47
    5 
  • trunk/LayoutTests/imported/w3c/web-platform-tests/service-workers/service-worker/dedicated-worker-service-worker-interception.https-expected.txt

    r267647 r288473  
    11
    2 Harness Error (FAIL), message = SyntaxError: Unexpected string literal './service-worker-interception-network-worker.js'. import call expects exactly one argument.
     2Harness Error (FAIL), message = SyntaxError: Unexpected string literal './service-worker-interception-network-worker.js'. import call expects one or two arguments.
    33
    44FAIL Top-level module loading should be intercepted by a service worker. assert_equals: expected "LOADED_FROM_SERVICE_WORKER" but got "LOADED_FROM_NETWORK"
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/dedicated-worker-parse-error-failure-expected.txt

    r264183 r288473  
    11CONSOLE MESSAGE: SyntaxError: Unexpected token ';'
    2 CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects exactly one argument.
     2CONSOLE MESSAGE: SyntaxError: Unexpected token '*'. import call expects one or two arguments.
    33
    44FAIL Classic worker construction for script with syntax error should dispatch an event named error. assert_equals: expected function "function Event() {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/workers/modules/dedicated-worker-options-credentials-expected.txt

    r267649 r288473  
    1 CONSOLE MESSAGE: SyntaxError: Unexpected string literal './credentials.py'. import call expects exactly one argument.
     1CONSOLE MESSAGE: SyntaxError: Unexpected string literal './credentials.py'. import call expects one or two arguments.
    22
    3 Harness Error (FAIL), message = SyntaxError: Unexpected string literal './credentials.py'. import call expects exactly one argument.
     3Harness Error (FAIL), message = SyntaxError: Unexpected string literal './credentials.py'. import call expects one or two arguments.
    44
    55PASS Test initialization: setting up cross-origin cookie
  • trunk/Source/JavaScriptCore/ChangeLog

    r288458 r288473  
     12022-01-24  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Support import assertion syntax
     4        https://bugs.webkit.org/show_bug.cgi?id=235312
     5
     6        Reviewed by Ross Kirsling.
     7
     8        This patch adds syntax support for import assertion[1].
     9        This does not add the actual feature propagating import assertion
     10        to the module request yet.
     11
     12        [1]: https://github.com/tc39/proposal-import-assertions
     13
     14        * bytecompiler/NodesCodegen.cpp:
     15        (JSC::ImportNode::emitBytecode):
     16        * parser/ASTBuilder.h:
     17        (JSC::ASTBuilder::createImportExpr):
     18        (JSC::ASTBuilder::createImportAssertionList):
     19        (JSC::ASTBuilder::appendImportAssertion):
     20        (JSC::ASTBuilder::createImportDeclaration):
     21        (JSC::ASTBuilder::createExportAllDeclaration):
     22        (JSC::ASTBuilder::createExportNamedDeclaration):
     23        * parser/NodeConstructors.h:
     24        (JSC::ImportNode::ImportNode):
     25        (JSC::ImportDeclarationNode::ImportDeclarationNode):
     26        (JSC::ExportAllDeclarationNode::ExportAllDeclarationNode):
     27        (JSC::ExportNamedDeclarationNode::ExportNamedDeclarationNode):
     28        * parser/Nodes.h:
     29        * parser/Parser.cpp:
     30        (JSC::Parser<LexerType>::parseImportAssertions):
     31        (JSC::Parser<LexerType>::parseImportDeclaration):
     32        (JSC::Parser<LexerType>::parseExportDeclaration):
     33        (JSC::Parser<LexerType>::parseMemberExpression):
     34        * parser/Parser.h:
     35        * parser/SyntaxChecker.h:
     36        (JSC::SyntaxChecker::createImportExpr):
     37        (JSC::SyntaxChecker::createImportAssertionList):
     38        (JSC::SyntaxChecker::appendImportAssertion):
     39        (JSC::SyntaxChecker::createImportDeclaration):
     40        (JSC::SyntaxChecker::createExportAllDeclaration):
     41        (JSC::SyntaxChecker::createExportNamedDeclaration):
     42        * runtime/JSGlobalObjectFunctions.cpp:
     43        (JSC::JSC_DEFINE_HOST_FUNCTION):
     44        * runtime/OptionsList.h:
     45
    1462022-01-24  Mark Lam  <mark.lam@apple.com>
    247
  • trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp

    r287544 r288473  
    225225{
    226226    RefPtr<RegisterID> importModule = generator.moveLinkTimeConstant(nullptr, LinkTimeConstant::importModule);
    227     CallArguments arguments(generator, nullptr, 1);
     227    CallArguments arguments(generator, nullptr, m_option ? 2 : 1);
    228228    generator.emitLoad(arguments.thisRegister(), jsUndefined());
    229229    generator.emitNode(arguments.argumentRegister(0), m_expr);
     230    if (m_option)
     231        generator.emitNode(arguments.argumentRegister(1), m_option);
    230232    return generator.emitCall(generator.finalDestination(dst, importModule.get()), importModule.get(), NoExpectedFunction, arguments, divot(), divotStart(), divotEnd(), DebuggableCall::No);
    231233}
  • trunk/Source/JavaScriptCore/parser/ASTBuilder.h

    r287531 r288473  
    112112    typedef ImportSpecifierNode* ImportSpecifier;
    113113    typedef ImportSpecifierListNode* ImportSpecifierList;
     114    typedef ImportAssertionListNode* ImportAssertionList;
    114115    typedef ExportSpecifierNode* ExportSpecifier;
    115116    typedef ExportSpecifierListNode* ExportSpecifierList;
     
    180181        return new (m_parserArena) SuperNode(location);
    181182    }
    182     ExpressionNode* createImportExpr(const JSTokenLocation& location, ExpressionNode* expr, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
    183     {
    184         auto* node = new (m_parserArena) ImportNode(location, expr);
     183    ExpressionNode* createImportExpr(const JSTokenLocation& location, ExpressionNode* expr, ExpressionNode* option, const JSTextPosition& start, const JSTextPosition& divot, const JSTextPosition& end)
     184    {
     185        auto* node = new (m_parserArena) ImportNode(location, expr, option);
    185186        setExceptionLocation(node, start, divot, end);
    186187        return node;
     
    812813    }
    813814
    814     StatementNode* createImportDeclaration(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName)
    815     {
    816         return new (m_parserArena) ImportDeclarationNode(location, importSpecifierList, moduleName);
    817     }
    818 
    819     StatementNode* createExportAllDeclaration(const JSTokenLocation& location, ModuleNameNode* moduleName)
    820     {
    821         return new (m_parserArena) ExportAllDeclarationNode(location, moduleName);
     815    ImportAssertionListNode* createImportAssertionList()
     816    {
     817        return new (m_parserArena) ImportAssertionListNode();
     818    }
     819
     820    void appendImportAssertion(ImportAssertionListNode* assertionList, const Identifier& key, const Identifier& value)
     821    {
     822        assertionList->append(key, value);
     823    }
     824
     825    StatementNode* createImportDeclaration(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
     826    {
     827        return new (m_parserArena) ImportDeclarationNode(location, importSpecifierList, moduleName, importAssertionList);
     828    }
     829
     830    StatementNode* createExportAllDeclaration(const JSTokenLocation& location, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
     831    {
     832        return new (m_parserArena) ExportAllDeclarationNode(location, moduleName, importAssertionList);
    822833    }
    823834
     
    832843    }
    833844
    834     StatementNode* createExportNamedDeclaration(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName)
    835     {
    836         return new (m_parserArena) ExportNamedDeclarationNode(location, exportSpecifierList, moduleName);
     845    StatementNode* createExportNamedDeclaration(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
     846    {
     847        return new (m_parserArena) ExportNamedDeclarationNode(location, exportSpecifierList, moduleName, importAssertionList);
    837848    }
    838849
  • trunk/Source/JavaScriptCore/parser/NodeConstructors.h

    r287531 r288473  
    180180    }
    181181
    182     inline ImportNode::ImportNode(const JSTokenLocation& location, ExpressionNode* expr)
    183         : ExpressionNode(location)
    184         , m_expr(expr)
     182    inline ImportNode::ImportNode(const JSTokenLocation& location, ExpressionNode* expr, ExpressionNode* option)
     183        : ExpressionNode(location)
     184        , m_expr(expr)
     185        , m_option(option)
    185186    {
    186187    }
     
    866867    }
    867868
    868     inline ImportDeclarationNode::ImportDeclarationNode(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName)
     869    inline ImportDeclarationNode::ImportDeclarationNode(const JSTokenLocation& location, ImportSpecifierListNode* importSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
    869870        : ModuleDeclarationNode(location)
    870871        , m_specifierList(importSpecifierList)
    871872        , m_moduleName(moduleName)
    872     {
    873     }
    874 
    875     inline ExportAllDeclarationNode::ExportAllDeclarationNode(const JSTokenLocation& location, ModuleNameNode* moduleName)
     873        , m_assertionList(importAssertionList)
     874    {
     875    }
     876
     877    inline ExportAllDeclarationNode::ExportAllDeclarationNode(const JSTokenLocation& location, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
    876878        : ModuleDeclarationNode(location)
    877879        , m_moduleName(moduleName)
     880        , m_assertionList(importAssertionList)
    878881    {
    879882    }
     
    892895    }
    893896
    894     inline ExportNamedDeclarationNode::ExportNamedDeclarationNode(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName)
     897    inline ExportNamedDeclarationNode::ExportNamedDeclarationNode(const JSTokenLocation& location, ExportSpecifierListNode* exportSpecifierList, ModuleNameNode* moduleName, ImportAssertionListNode* importAssertionList)
    895898        : ModuleDeclarationNode(location)
    896899        , m_specifierList(exportSpecifierList)
    897900        , m_moduleName(moduleName)
     901        , m_assertionList(importAssertionList)
    898902    {
    899903    }
  • trunk/Source/JavaScriptCore/parser/Nodes.h

    r287531 r288473  
    628628    class ImportNode final : public ExpressionNode, public ThrowableExpressionData {
    629629    public:
    630         ImportNode(const JSTokenLocation&, ExpressionNode*);
     630        ImportNode(const JSTokenLocation&, ExpressionNode*, ExpressionNode*);
    631631
    632632    private:
     
    635635
    636636        ExpressionNode* m_expr;
     637        ExpressionNode* m_option;
    637638    };
    638639
     
    20582059    };
    20592060
     2061    class ImportAssertionListNode final : public ParserArenaDeletable {
     2062        JSC_MAKE_PARSER_ARENA_DELETABLE_ALLOCATED(ImportAssertionListNode);
     2063    public:
     2064        using Assertions = Vector<std::tuple<const Identifier*, const Identifier*>, 3>;
     2065
     2066        const Assertions& assertions() const { return m_assertions; }
     2067        void append(const Identifier& key, const Identifier& value)
     2068        {
     2069            m_assertions.append(std::tuple { &key, &value });
     2070        }
     2071
     2072    private:
     2073        Assertions m_assertions;
     2074    };
     2075
    20602076    class ModuleDeclarationNode : public StatementNode {
    20612077    public:
     
    20702086    class ImportDeclarationNode final : public ModuleDeclarationNode {
    20712087    public:
    2072         ImportDeclarationNode(const JSTokenLocation&, ImportSpecifierListNode*, ModuleNameNode*);
     2088        ImportDeclarationNode(const JSTokenLocation&, ImportSpecifierListNode*, ModuleNameNode*, ImportAssertionListNode*);
    20732089
    20742090        ImportSpecifierListNode* specifierList() const { return m_specifierList; }
    20752091        ModuleNameNode* moduleName() const { return m_moduleName; }
     2092        ImportAssertionListNode* assertionList() const { return m_assertionList; }
    20762093
    20772094    private:
     
    20812098        ImportSpecifierListNode* m_specifierList;
    20822099        ModuleNameNode* m_moduleName;
     2100        ImportAssertionListNode* m_assertionList;
    20832101    };
    20842102
    20852103    class ExportAllDeclarationNode final : public ModuleDeclarationNode {
    20862104    public:
    2087         ExportAllDeclarationNode(const JSTokenLocation&, ModuleNameNode*);
     2105        ExportAllDeclarationNode(const JSTokenLocation&, ModuleNameNode*, ImportAssertionListNode*);
    20882106
    20892107        ModuleNameNode* moduleName() const { return m_moduleName; }
     2108        ImportAssertionListNode* assertionList() const { return m_assertionList; }
    20902109
    20912110    private:
     
    20942113
    20952114        ModuleNameNode* m_moduleName;
     2115        ImportAssertionListNode* m_assertionList;
    20962116    };
    20972117
     
    21512171    class ExportNamedDeclarationNode final : public ModuleDeclarationNode {
    21522172    public:
    2153         ExportNamedDeclarationNode(const JSTokenLocation&, ExportSpecifierListNode*, ModuleNameNode*);
     2173        ExportNamedDeclarationNode(const JSTokenLocation&, ExportSpecifierListNode*, ModuleNameNode*, ImportAssertionListNode*);
    21542174
    21552175        ExportSpecifierListNode* specifierList() const { return m_specifierList; }
    21562176        ModuleNameNode* moduleName() const { return m_moduleName; }
     2177        ImportAssertionListNode* assertionList() const { return m_assertionList; }
    21572178
    21582179    private:
     
    21612182        ExportSpecifierListNode* m_specifierList;
    21622183        ModuleNameNode* m_moduleName { nullptr };
     2184        ImportAssertionListNode* m_assertionList { nullptr };
    21632185    };
    21642186
  • trunk/Source/JavaScriptCore/parser/Parser.cpp

    r284435 r288473  
    35773577
    35783578template <typename LexerType>
     3579template <class TreeBuilder> typename TreeBuilder::ImportAssertionList Parser<LexerType>::parseImportAssertions(TreeBuilder& context)
     3580{
     3581    auto assertionList = context.createImportAssertionList();
     3582    consumeOrFail(OPENBRACE, "Expected opening '{' at the start of import assertion");
     3583    while (!match(CLOSEBRACE)) {
     3584        failIfFalse(matchIdentifierOrKeyword() || match(STRING), "Expected an assertion key");
     3585        auto key = m_token.m_data.ident;
     3586        next();
     3587        consumeOrFail(COLON, "Expected ':' after assertion key");
     3588        failIfFalse(match(STRING), "Expected an assertion value");
     3589        auto value = m_token.m_data.ident;
     3590        next();
     3591        context.appendImportAssertion(assertionList, *key, *value);
     3592        if (!consume(COMMA))
     3593            break;
     3594    }
     3595    handleProductionOrFail2(CLOSEBRACE, "}", "end", "import assertion");
     3596    return assertionList;
     3597}
     3598
     3599template <typename LexerType>
    35793600template <class TreeBuilder> TreeStatement Parser<LexerType>::parseImportDeclaration(TreeBuilder& context)
    35803601{
     
    35883609    if (match(STRING)) {
    35893610        // import ModuleSpecifier ;
     3611        // import ModuleSpecifier [no LineTerminator here] AssertClause ;
    35903612        auto moduleName = parseModuleName(context);
    35913613        failIfFalse(moduleName, "Cannot parse the module name");
     3614
     3615        typename TreeBuilder::ImportAssertionList assertionList = 0;
     3616        if (Options::useImportAssertion() && !m_lexer->hasLineTerminatorBeforeToken() && matchContextualKeyword(m_vm.propertyNames->builtinNames().assertPublicName())) {
     3617            next();
     3618            assertionList = parseImportAssertions(context);
     3619            failIfFalse(assertionList, "Unable to parse import assertion");
     3620        }
     3621
    35923622        failIfFalse(autoSemiColon(), "Expected a ';' following a targeted import declaration");
    3593         return context.createImportDeclaration(importLocation, specifierList, moduleName);
     3623        return context.createImportDeclaration(importLocation, specifierList, moduleName, assertionList);
    35943624    }
    35953625
     
    36413671    auto moduleName = parseModuleName(context);
    36423672    failIfFalse(moduleName, "Cannot parse the module name");
     3673
     3674    // [no LineTerminator here] AssertClause ;
     3675    typename TreeBuilder::ImportAssertionList assertionList = 0;
     3676    if (Options::useImportAssertion() && !m_lexer->hasLineTerminatorBeforeToken() && matchContextualKeyword(m_vm.propertyNames->builtinNames().assertPublicName())) {
     3677        next();
     3678        assertionList = parseImportAssertions(context);
     3679        failIfFalse(assertionList, "Unable to parse import assertion");
     3680    }
     3681
    36433682    failIfFalse(autoSemiColon(), "Expected a ';' following a targeted import declaration");
    36443683
    3645     return context.createImportDeclaration(importLocation, specifierList, moduleName);
     3684    return context.createImportDeclaration(importLocation, specifierList, moduleName, assertionList);
    36463685}
    36473686
     
    37153754        auto moduleName = parseModuleName(context);
    37163755        failIfFalse(moduleName, "Cannot parse the 'from' clause");
     3756
     3757        // [no LineTerminator here] AssertClause ;
     3758        typename TreeBuilder::ImportAssertionList assertionList = 0;
     3759        if (Options::useImportAssertion() && !m_lexer->hasLineTerminatorBeforeToken() && matchContextualKeyword(m_vm.propertyNames->builtinNames().assertPublicName())) {
     3760            next();
     3761            assertionList = parseImportAssertions(context);
     3762            failIfFalse(assertionList, "Unable to parse import assertion");
     3763        }
     3764
    37173765        failIfFalse(autoSemiColon(), "Expected a ';' following a targeted export declaration");
    37183766
     
    37233771            auto specifier = context.createExportSpecifier(specifierLocation, *localName, *exportedName);
    37243772            context.appendExportSpecifier(specifierList, specifier);
    3725             return context.createExportNamedDeclaration(exportLocation, specifierList, moduleName);
    3726         }
    3727 
    3728         return context.createExportAllDeclaration(exportLocation, moduleName);
     3773            return context.createExportNamedDeclaration(exportLocation, specifierList, moduleName, assertionList);
     3774        }
     3775
     3776        return context.createExportAllDeclaration(exportLocation, moduleName, assertionList);
    37293777    }
    37303778
     
    38483896
    38493897        typename TreeBuilder::ModuleName moduleName = 0;
     3898        typename TreeBuilder::ImportAssertionList assertionList = 0;
    38503899        if (matchContextualKeyword(m_vm.propertyNames->from)) {
    38513900            next();
    38523901            moduleName = parseModuleName(context);
    38533902            failIfFalse(moduleName, "Cannot parse the 'from' clause");
     3903
     3904            // [no LineTerminator here] AssertClause ;
     3905            if (Options::useImportAssertion() && !m_lexer->hasLineTerminatorBeforeToken() && matchContextualKeyword(m_vm.propertyNames->builtinNames().assertPublicName())) {
     3906                next();
     3907                assertionList = parseImportAssertions(context);
     3908                failIfFalse(assertionList, "Unable to parse import assertion");
     3909            }
    38543910        } else
    38553911            semanticFailIfTrue(hasReferencedModuleExportNames, "Cannot use module export names if they reference variable names in the current module");
     
    38733929        }
    38743930
    3875         return context.createExportNamedDeclaration(exportLocation, specifierList, moduleName);
     3931        return context.createExportNamedDeclaration(exportLocation, specifierList, moduleName, assertionList);
    38763932    }
    38773933
     
    51375193        } else {
    51385194            semanticFailIfTrue(newCount, "Cannot use new with import");
    5139             consumeOrFail(OPENPAREN, "import call expects exactly one argument");
     5195            consumeOrFail(OPENPAREN, "import call expects one or two arguments");
    51405196            TreeExpression expr = parseAssignmentExpression(context);
    51415197            failIfFalse(expr, "Cannot parse expression");
    5142             consumeOrFail(CLOSEPAREN, "import call expects exactly one argument");
    5143             base = context.createImportExpr(location, expr, expressionStart, expressionEnd, lastTokenEndPosition());
     5198            TreeExpression optionExpression = 0;
     5199            if (consume(COMMA)) {
     5200                if (!match(CLOSEPAREN)) {
     5201                    optionExpression = parseAssignmentExpression(context);
     5202                    failIfFalse(optionExpression, "Cannot parse expression");
     5203                    consume(COMMA);
     5204                }
     5205            }
     5206            consumeOrFail(CLOSEPAREN, "import call expects one or two arguments");
     5207            base = context.createImportExpr(location, expr, optionExpression, expressionStart, expressionEnd, lastTokenEndPosition());
    51445208        }
    51455209    } else if (!baseIsNewTarget) {
  • trunk/Source/JavaScriptCore/parser/Parser.h

    r288261 r288473  
    17851785    template <class TreeBuilder> typename TreeBuilder::ImportSpecifier parseImportClauseItem(TreeBuilder&, ImportSpecifierType);
    17861786    template <class TreeBuilder> typename TreeBuilder::ModuleName parseModuleName(TreeBuilder&);
     1787    template <class TreeBuilder> typename TreeBuilder::ImportAssertionList parseImportAssertions(TreeBuilder&);
    17871788    template <class TreeBuilder> TreeStatement parseImportDeclaration(TreeBuilder&);
    17881789    template <class TreeBuilder> typename TreeBuilder::ExportSpecifier parseExportSpecifier(TreeBuilder& context, Vector<std::pair<const Identifier*, const Identifier*>>& maybeExportedLocalNames, bool& hasKeywordForLocalBindings, bool& hasReferencedModuleExportNames);
  • trunk/Source/JavaScriptCore/parser/SyntaxChecker.h

    r279447 r288473  
    8787        TaggedTemplateExpr, YieldExpr, AwaitExpr,
    8888        ModuleNameResult, PrivateIdentifier,
    89         ImportSpecifierResult, ImportSpecifierListResult,
     89        ImportSpecifierResult, ImportSpecifierListResult, ImportAssertionListResult,
    9090        ExportSpecifierResult, ExportSpecifierListResult,
    9191
     
    129129    typedef int ImportSpecifier;
    130130    typedef int ImportSpecifierList;
     131    typedef int ImportAssertionList;
    131132    typedef int ExportSpecifier;
    132133    typedef int ExportSpecifierList;
     
    160161    ExpressionType createUnaryPlus(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
    161162    ExpressionType createVoid(const JSTokenLocation&, ExpressionType) { return UnaryExpr; }
    162     ExpressionType createImportExpr(const JSTokenLocation&, ExpressionType, int, int, int) { return ImportExpr; }
     163    ExpressionType createImportExpr(const JSTokenLocation&, ExpressionType, ExpressionType, int, int, int) { return ImportExpr; }
    163164    ExpressionType createThisExpr(const JSTokenLocation&) { return ThisExpr; }
    164165    ExpressionType createSuperExpr(const JSTokenLocation&) { return SuperExpr; }
     
    279280    ImportSpecifierList createImportSpecifierList() { return ImportSpecifierListResult; }
    280281    void appendImportSpecifier(ImportSpecifierList, ImportSpecifier) { }
    281     int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName) { return StatementResult; }
    282     int createExportAllDeclaration(const JSTokenLocation&, ModuleName) { return StatementResult; }
     282    ImportAssertionList createImportAssertionList() { return ImportAssertionListResult; }
     283    void appendImportAssertion(ImportAssertionList, const Identifier&, const Identifier&) { }
     284    int createImportDeclaration(const JSTokenLocation&, ImportSpecifierList, ModuleName, ImportAssertionList) { return StatementResult; }
     285    int createExportAllDeclaration(const JSTokenLocation&, ModuleName, ImportAssertionList) { return StatementResult; }
    283286    int createExportDefaultDeclaration(const JSTokenLocation&, int, const Identifier&) { return StatementResult; }
    284287    int createExportLocalDeclaration(const JSTokenLocation&, int) { return StatementResult; }
    285     int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName) { return StatementResult; }
     288    int createExportNamedDeclaration(const JSTokenLocation&, ExportSpecifierList, ModuleName, ImportAssertionList) { return StatementResult; }
    286289    ExportSpecifier createExportSpecifier(const JSTokenLocation&, const Identifier&, const Identifier&) { return ExportSpecifierResult; }
    287290    ExportSpecifierList createExportSpecifierList() { return ExportSpecifierListResult; }
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp

    r287303 r288473  
    823823
    824824    auto sourceOrigin = callFrame->callerSourceOrigin(vm);
    825     RELEASE_ASSERT(callFrame->argumentCount() == 1);
     825    RELEASE_ASSERT(callFrame->argumentCount() >= 1);
    826826    auto* specifier = callFrame->uncheckedArgument(0).toString(globalObject);
    827827    RETURN_IF_EXCEPTION(scope, JSValue::encode(promise->rejectWithCaughtException(globalObject, scope)));
  • trunk/Source/JavaScriptCore/runtime/OptionsList.h

    r287136 r288473  
    542542    v(Bool, useAtMethod, true, Normal, "Expose the at() method on Array, %TypedArray%, and String.") \
    543543    v(Bool, useHasOwn, true, Normal, "Expose the Object.hasOwn method") \
     544    v(Bool, useImportAssertion, false, Normal, "Enable import assertion.") \
    544545    v(Bool, useIntlEnumeration, true, Normal, "Expose the Intl enumeration APIs.") \
    545546    v(Bool, useSharedArrayBuffer, false, Normal, nullptr) \
Note: See TracChangeset for help on using the changeset viewer.