mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1065883: Fail if we try to import variables in the global section without a stdlib parameter; r=luke
--HG-- extra : rebase_source : c73ee1741babec4a4234f0e452dc64714ef7702d
This commit is contained in:
parent
b1dd2e4484
commit
d72d0006b6
@ -3588,19 +3588,23 @@ CheckGlobalDotImport(ModuleCompiler &m, PropertyName *varName, ParseNode *initNo
|
||||
ParseNode *global = DotBase(base);
|
||||
PropertyName *mathOrSimd = DotMember(base);
|
||||
|
||||
if (!IsUseOfName(global, m.module().globalArgumentName())) {
|
||||
PropertyName *globalName = m.module().globalArgumentName();
|
||||
if (!globalName)
|
||||
return m.fail(base, "import statement requires the module have a stdlib parameter");
|
||||
|
||||
if (!IsUseOfName(global, globalName)) {
|
||||
if (global->isKind(PNK_DOT)) {
|
||||
return m.failName(base, "imports can have at most two dot accesses "
|
||||
"(e.g. %s.Math.sin)", m.module().globalArgumentName());
|
||||
"(e.g. %s.Math.sin)", globalName);
|
||||
}
|
||||
return m.failName(base, "expecting %s.*", m.module().globalArgumentName());
|
||||
return m.failName(base, "expecting %s.*", globalName);
|
||||
}
|
||||
|
||||
if (mathOrSimd == m.cx()->names().Math)
|
||||
return CheckGlobalMathImport(m, initNode, varName, field);
|
||||
if (mathOrSimd == m.cx()->names().SIMD)
|
||||
return CheckGlobalSimdImport(m, initNode, varName, field);
|
||||
return m.failName(base, "expecting %s.{Math|SIMD}", m.module().globalArgumentName());
|
||||
return m.failName(base, "expecting %s.{Math|SIMD}", globalName);
|
||||
}
|
||||
|
||||
if (!base->isKind(PNK_NAME))
|
||||
|
@ -11,6 +11,7 @@ assertAsmTypeFail(USE_ASM + 'function f(){} return g');
|
||||
assertAsmTypeFail(USE_ASM + 'function f(){} function f(){} return f');
|
||||
assertAsmTypeFail(USE_ASM + 'function f(){}; function g(){}; return {f, g}');
|
||||
assertAsmTypeFail(USE_ASM + 'var f=0; function f(){} return f');
|
||||
assertAsmTypeFail(USE_ASM + 'var f=glob.Math.imul; return {}');
|
||||
assertAsmTypeFail('glob', USE_ASM + 'var f=glob.Math.imul; function f(){} return f');
|
||||
assertAsmTypeFail('glob','foreign', USE_ASM + 'var f=foreign.foo; function f(){} return f');
|
||||
assertAsmTypeFail(USE_ASM + 'function f(){} var f=[f,f]; return f');
|
||||
|
Loading…
Reference in New Issue
Block a user