Skip to content

Conversation

DuncanUszkay1
Copy link
Contributor

Issue: #1181

When we were resolving a function from an identifier, we would call the resolveFunction method without any typeArguments. This guarantees an assertion failure in the event that the function requires type parameters.

This PR adds a check in the compileIdentifierExpression call just before it tries to resolve the function which will print out a nicer error message.

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

Before:

Results in:

ERROR: AssertionError: assertion failed

After

Results in:

ERROR TS2554: Expected 4 arguments, but got 0.

   let x = doit<String("hey!");
           ~~~~
 in main.ts(9,11)

ERROR AS225: Expression cannot be represented by a type.

   let x = doit<String("hey!");
                ~~~~~~~~~~~~~~
 in main.ts(9,16)

@DuncanUszkay1 DuncanUszkay1 force-pushed the fix-angle-bracket-assert branch from 45b3bf4 to a5f9eb4 Compare March 24, 2020 00:39
Co-Authored-By: Max Graey <maxgraey@gmail.com>
@dcodeIO dcodeIO merged commit 0553d16 into AssemblyScript:master Mar 24, 2020
@dcodeIO
Copy link
Member

dcodeIO commented Mar 24, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants