cat-language
cat-language copied to clipboard
popFunc doesn't actually ensure that it pops an instruction
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
.