Closed Bug 1314128 Opened 8 years ago Closed 8 years ago

Assertion failure: sc->isFunctionBox() for await expression in module code

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: anba, Assigned: arai)

References

Details

Attachments

(1 file)

Test case:
---
parseModule("await 0")
---

Triggers this assertion failure: "Assertion failure: sc->isFunctionBox()"

Back trace:
---
#0  0x00000000010560fc in js::frontend::BytecodeEmitter::emitYield (this=0x7fffffffb3b8, pn=0x7ffff69fc0e0)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:7405
#1  0x000000000105cecb in js::frontend::BytecodeEmitter::emitTree (this=0x7fffffffb3b8, pn=0x7ffff69fc0e0, 
    emitLineNote=js::frontend::BytecodeEmitter::EMIT_LINENOTE) at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:9349
#2  0x00000000010570f5 in js::frontend::BytecodeEmitter::emitStatement (this=0x7fffffffb3b8, pn=0x7ffff69fc110)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:7656
#3  0x000000000105cf1b in js::frontend::BytecodeEmitter::emitTree (this=0x7fffffffb3b8, pn=0x7ffff69fc110, 
    emitLineNote=js::frontend::BytecodeEmitter::EMIT_LINENOTE) at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:9359
#4  0x0000000001056e5a in js::frontend::BytecodeEmitter::emitStatementList (this=0x7fffffffb3b8, pn=0x7ffff69fc050)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:7601
#5  0x000000000105cef3 in js::frontend::BytecodeEmitter::emitTree (this=0x7fffffffb3b8, pn=0x7ffff69fc050, 
    emitLineNote=js::frontend::BytecodeEmitter::EMIT_LINENOTE) at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:9354
#6  0x000000000104afd7 in js::frontend::BytecodeEmitter::emitScript (this=0x7fffffffb3b8, body=0x7ffff69fc050)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeEmitter.cpp:4189
#7  0x000000000103cb7a in BytecodeCompiler::compileModule (this=0x7fffffffb800) at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeCompiler.cpp:414
#8  0x000000000103d882 in js::frontend::CompileModule (cx=0x7ffff6965000, optionsInput=..., srcBuf=..., alloc=..., sourceObjectOut=0x0)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeCompiler.cpp:603
#9  0x000000000103d967 in js::frontend::CompileModule (cx=0x7ffff6965000, options=..., srcBuf=...)
    at /home/andre/hg/mozilla-inbound/js/src/frontend/BytecodeCompiler.cpp:614
#10 0x00000000004481eb in ParseModule (cx=0x7ffff6965000, argc=1, vp=0x7ffff161f090) at /home/andre/hg/mozilla-inbound/js/src/shell/js.cpp:3987
...
---
TOK_AWAIT is returned in module even if it's not in async function, so we should throw error if it's |!pc->isAsync()|.
Assignee: nobody → arai.unmht
Status: NEW → ASSIGNED
In module, await is Future Reserved Words.
  https://tc39.github.io/ecma262/#sec-future-reserved-words
We handle it by AutoAwaitIsKeyword in moduleBody, but it means we return TOK_AWAIT outside of async function,
and unaryExpr parses await expression regardless of the context.

Now it throws SyntaxError when it founds TOK_AWAIT outside async function.
Attachment #8806148 - Flags: review?(till)
Comment on attachment 8806148 [details] [diff] [review]
Do not parse await expression in module.

Review of attachment 8806148 [details] [diff] [review]:
-----------------------------------------------------------------

r=me
Attachment #8806148 - Flags: review?(till) → review+
https://hg.mozilla.org/mozilla-central/rev/d2526689ef03
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: