Closed Bug 877908 Opened 11 years ago Closed 11 years ago

Confusing error message from "use asm" with "use strict"

Categories

(Core :: JavaScript Engine, defect)

x86_64
macOS
defect
Not set
minor

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: jruderman, Assigned: bbouvier)

Details

(Keywords: testcase)

Attachments

(1 file, 1 obsolete file)

js> (function() { "use asm"; "use strict"; function g(){} return g; })

typein:14:0 warning: asm.js type error: asm.js module must end with a return export statement:
typein:14:0 warning: (function() { "use asm"; "use strict"; function g(){} return
typein:14:0 warning: .^

Expected one of the following:
* "use asm" precludes other directives
* unsupported kind of statement in asm.js module
Attached patch proposed fix + test (obsolete) — Splinter Review
The asmjs spec is not precise whether the use of "use asm" should preclude other directives, so this patch stays consistent with the rest of the function.
Assignee: general → bbouvier
Status: NEW → ASSIGNED
Attachment #756786 - Flags: review?(luke)
Summary: Confusing error message from "use asm" → Confusing error message from "use asm" with "use strict"
Comment on attachment 756786 [details] [diff] [review]
proposed fix + test

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

Thanks!

::: js/src/ion/AsmJS.cpp
@@ +2574,5 @@
> +    *stmtIter = NextNonEmptyStatement(firstStatement);
> +    if (*stmtIter
> +        && IsExpressionStatement(*stmtIter)
> +        && ExpressionStatementExpr(*stmtIter)->isKind(PNK_STRING))
> +        return m.fail(*stmtIter, "\"use asm\" precludes other directives");

SM style is, when the condition is multi-line, { brace } the then branch, even if it is a single line (with the opening { on a new line).  So,

if (....
    ...)
{
    return ...
}
Attachment #756786 - Flags: review?(luke) → review+
Carrying r+ with fixed nit.
Attachment #756786 - Attachment is obsolete: true
Attachment #759393 - Flags: review+
Keywords: checkin-needed
Whiteboard: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/0a027c965a33
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: