Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DuncanUszkay1 opened this issue Mar 23, 2020 · 0 comments

Comments

@DuncanUszkay1
Copy link
Contributor

DuncanUszkay1 commented Mar 23, 2020

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
Projects
None yet
Development

No branches or pull requests

2 participants