Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9035,10 +9035,29 @@ export class Compiler extends DiagnosticEmitter {
}
case ElementKind.FunctionPrototype: {
let functionPrototype = <FunctionPrototype>target;
let typeParameterNodes = functionPrototype.typeParameterNodes;

if (typeParameterNodes && typeParameterNodes.length != 0) {
this.error(
DiagnosticCode.Type_argument_expected,
expression.range
);
break; // also diagnose 'not a value at runtime'
}

let functionInstance = this.resolver.resolveFunction(functionPrototype, null);
if (!functionInstance) return module.unreachable();
if (!this.compileFunction(functionInstance)) return module.unreachable();
this.currentType = functionInstance.type;

if (functionInstance.hasDecorator(DecoratorFlags.Builtin)) {
this.error(
DiagnosticCode.Not_implemented_0,
expression.range, "First-class built-ins"
);
return module.unreachable();
}

let offset = this.ensureRuntimeFunction(functionInstance);
return this.options.isWasm64
? module.i64(i64_low(offset), i64_high(offset))
Expand Down
15 changes: 15 additions & 0 deletions tests/compiler/issues/2737.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"stderr": [
"TS1140: Type argument expected.",
"foo.bar;",
"AS234: Expression does not compile to a value at runtime.",
"foo.bar;",
"TS1140: Type argument expected.",
"memory.data;",
"AS234: Expression does not compile to a value at runtime.",
"memory.data;",
"AS100: Not implemented: First-class built-ins",
"atomic.fence;",
"EOF"
]
}
12 changes: 12 additions & 0 deletions tests/compiler/issues/2737.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace foo {
export function bar<T>(): void {}
}

// Should error from missing type arguments:
foo.bar;
memory.data;

// Should error from lacking first-class builtins:
atomic.fence;

ERROR("EOF");