Skip to content

Referencing a function prototype with no type parameters leads to assertion failure #1181

Closed

Description

@DuncanUszkay1

If you reference a function prototype that requires a type parameter and omit that type parameter, you get an assertion failure rather than a helpful error:

function doit<T,X,O,N>(x: T): T {
  return x
}
export function test(x: i32): void {
  let x = doit;
}

Returns

ERROR: AssertionError: assertion failed
    at assert (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/std/portable/index.js:184:9)
    at Resolver.resolveFunction (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/resolver.ts:2691:7)
    at Compiler.compileIdentifierExpression (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:7954:46)
    at Compiler.compileExpression (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:3327:21)
    at Compiler.compileBinaryExpression (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:3735:25)
    at Compiler.compileExpression (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:3302:21)
    at Compiler.compileVariableStatement (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:2868:25)
    at Compiler.compileStatement (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:1984:21)
    at Compiler.compileStatements (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:2031:23)
    at Compiler.compileFunctionBody (/Users/duncanuszkay/src/github.com/Shopify/as-fork/assemblyscript/src/compiler.ts:1393:20)

This came up for us when we made this typo:

let x = doit<String("hey!"); //Forgot the other >

Going to open up a PR to fix this momentarily

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions