Skip to content

Commit 9af14b8

Browse files
authored
Properly resolve function type from function name (AssemblyScript#833)
1 parent 22c4cf4 commit 9af14b8

File tree

6 files changed

+8804
-0
lines changed

6 files changed

+8804
-0
lines changed

src/compiler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8103,6 +8103,7 @@ export class Compiler extends DiagnosticEmitter {
81038103
);
81048104

81058105
// Try to eliminate unnecesssary branches if the condition is constant
8106+
// FIXME: skips common denominator, inconsistently picking left type
81068107
if (
81078108
getExpressionId(condExpr) == ExpressionId.Const &&
81088109
getExpressionType(condExpr) == NativeType.I32

src/resolver.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,11 @@ export class Resolver extends DiagnosticEmitter {
10251025
): Type | null {
10261026
var element = this.lookupIdentifierExpression(node, ctxFlow, ctxElement, reportMode);
10271027
if (!element) return null;
1028+
if (element.kind == ElementKind.FUNCTION_PROTOTYPE) {
1029+
let instance = this.resolveFunction(<FunctionPrototype>element, null, makeMap(), reportMode);
1030+
if (!instance) return null;
1031+
element = instance;
1032+
}
10281033
var type = this.getTypeOfElement(element);
10291034
if (!type) {
10301035
if (reportMode == ReportMode.REPORT) {

0 commit comments

Comments
 (0)