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

popFunc doesn't actually ensure that it pops an instruction #1

Open
sandersn opened this issue Jan 4, 2018 · 1 comment
Open

popFunc doesn't actually ensure that it pops an instruction #1

sandersn opened this issue Jan 4, 2018 · 1 comment
Assignees

Comments

@sandersn
Copy link

sandersn commented Jan 4, 2018

It's probably an artifact from the translation from C#, but popFunc doesn't actually ensure that it pops an instruction. popType<T> uses this.pop() as T which is just a cast (assertion) in Typescript. So I think this error will never occur.

This pattern:

function f<T>(): T {
  return whatever as T;
}

Is not useful in Typescript and is misleading when coming from C#, because it's basically just a cast. I'd recommend replacing popType with this.pop() as T.

@sandersn
Copy link
Author

sandersn commented Jan 4, 2018

the error's predicate should probably be if (!(i instanceof CatInstruction)) ...

@cdiggins cdiggins self-assigned this Jan 4, 2018
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

No branches or pull requests

2 participants