Bug 168844 - ASSERTION FAILED: "We should only declare a function as a lexically scoped variable in scopes where var declarations aren't allowed. ..." for function redeclaration with async function module export
Summary: ASSERTION FAILED: "We should only declare a function as a lexically scoped va...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-02-24 14:18 PST by André Bargull
Modified: 2017-06-03 04:25 PDT (History)
8 users (show)

See Also:


Attachments
Patch (4.48 KB, patch)
2017-06-02 02:55 PDT, Yusuke Suzuki
saam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description André Bargull 2017-02-24 14:18:36 PST
svn revision: 212968

Test case:
---
checkModuleSyntax("function f(){} export async function f() {}");
---

Fails with:
---
ASSERTION FAILED: We should only declare a function as a lexically scoped variable in scopes where var declarations aren't allowed. I.e, in strict mode and not at the top-level scope of a function or program.
---

Stacktrace:
---
#0  0x00007ffff6d97a4e in WTFCrash () at ../../Source/WTF/wtf/Assertions.cpp:323
#1  0x00007ffff698fad8 in JSC::Scope::declareFunction (this=0x7fffffffa100, ident=0x7fffef5d9200, declareAsVar=false, isSloppyModeHoistingCandidate=false)
    at ../../Source/JavaScriptCore/parser/Parser.h:397
#2  0x00007ffff699d3e1 in JSC::Parser<JSC::Lexer<unsigned char> >::declareFunction (this=0x7fffffffa0f0, ident=0x7fffef5d9200) at ../../Source/JavaScriptCore/parser/Parser.h:1228
#3  0x00007ffff69cf8ef in JSC::Parser<JSC::Lexer<unsigned char> >::parseAsyncFunctionDeclaration<JSC::ASTBuilder> (this=0x7fffffffa0f0, context=..., 
    exportType=JSC::Parser<JSC::Lexer<unsigned char> >::ExportType::Exported, declarationDefaultContext=JSC::DeclarationDefaultContext::Standard) at ../../Source/JavaScriptCore/parser/Parser.cpp:2474
#4  0x00007ffff69bc262 in JSC::Parser<JSC::Lexer<unsigned char> >::parseExportDeclaration<JSC::ASTBuilder> (this=0x7fffffffa0f0, context=...) at ../../Source/JavaScriptCore/parser/Parser.cpp:3301
#5  0x00007ffff69ad691 in JSC::Parser<JSC::Lexer<unsigned char> >::parseModuleSourceElements<JSC::ASTBuilder> (this=0x7fffffffa0f0, context=..., parseMode=JSC::SourceParseMode::ModuleAnalyzeMode)
    at ../../Source/JavaScriptCore/parser/Parser.cpp:380
#6  0x00007ffff699dbf1 in JSC::Parser<JSC::Lexer<unsigned char> >::parseInner (this=0x7fffffffa0f0, calleeName=..., parseMode=JSC::SourceParseMode::ModuleAnalyzeMode)
    at ../../Source/JavaScriptCore/parser/Parser.cpp:207
#7  0x00007ffff62f27a1 in JSC::Parser<JSC::Lexer<unsigned char> >::parse<JSC::ModuleProgramNode> (this=0x7fffffffa0f0, error=..., calleeName=..., parseMode=JSC::SourceParseMode::ModuleAnalyzeMode)
    at ../../Source/JavaScriptCore/parser/Parser.h:1811
#8  0x00007ffff62f2167 in JSC::parse<JSC::ModuleProgramNode> (vm=0x7fffaf000000, source=..., name=..., builtinMode=JSC::JSParserBuiltinMode::NotBuiltin, strictMode=JSC::JSParserStrictMode::Strict, 
    scriptMode=JSC::JSParserScriptMode::Module, parseMode=JSC::SourceParseMode::ModuleAnalyzeMode, superBinding=JSC::SuperBinding::NotNeeded, error=..., positionBeforeLastNewline=0x0, 
    defaultConstructorKind=JSC::ConstructorKind::None, derivedContextType=JSC::DerivedContextType::None, evalContextType=JSC::EvalContextType::None, debuggerParseData=0x0)
    at ../../Source/JavaScriptCore/parser/Parser.h:1900
#9  0x00007ffff6aea605 in JSC::checkModuleSyntax (exec=0x7fffffffc740, source=..., error=...) at ../../Source/JavaScriptCore/runtime/Completion.cpp:79
#10 0x0000000000466689 in functionCheckModuleSyntax (exec=0x7fffffffc740) at ../../Source/JavaScriptCore/jsc.cpp:2939
...
---
Comment 1 Radar WebKit Bug Importer 2017-02-26 13:38:52 PST
<rdar://problem/30724820>
Comment 2 Yusuke Suzuki 2017-06-02 02:48:16 PDT
Working on it right now.
Comment 3 Yusuke Suzuki 2017-06-02 02:55:15 PDT
Created attachment 311811 [details]
Patch
Comment 4 Saam Barati 2017-06-02 08:56:09 PDT
Comment on attachment 311811 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311811&action=review

> JSTests/modules/async-function-export.js:1
> +function f()

What are the semantics for this? If I tried to call “f” below, which one would I call?
Comment 5 Yusuke Suzuki 2017-06-03 04:20:37 PDT
Comment on attachment 311811 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=311811&action=review

Thanks.

>> JSTests/modules/async-function-export.js:1
>> +function f()
> 
> What are the semantics for this? If I tried to call “f” below, which one would I call?

Latter one. Same as

function f() { }
function f() { } case.
Comment 6 Yusuke Suzuki 2017-06-03 04:25:22 PDT
Committed r217755: <http://trac.webkit.org/changeset/217755>