bug: vscode extension warns about possible nulls where it's not possible
Why I get this yellow wave line under the comparsion? I thought this was already fixed long ago (though that might have been in the compiler, not the vsc extension)
I would argue that this is a more of a limitation / missing feature than a bug (as in code that's supposed to work one way but actually works a different way). (Yes it's a bug from our pov ofc).
The type checker apparently just doesn't have the ability to narrow / infer the type of anything other than a local variable. And I think it's possible in theory (obviously typescript is able to do so)
As this example shows, typescript:
- can narrow the type of a non-local variable (good)
- but it doesn't notice that a non-local variable's type can be changed by other code after narrowing (bad). In this sense, Monkey C is actually safer than TypeScript
I would argue that this is a more of a limitation / missing feature than a bug (as in code that's supposed to work one way but actually works a different way). (Yes it's a bug from our pov ofc).
The type checker apparently just doesn't have the ability to narrow / infer the type of anything other than a local variable. And I think it's possible in theory (obviously typescript is able to do so)
As this example shows, typescript:
- can narrow the type of a non-local variable (good)
- but it doesn't notice that a non-local variable's type can be changed by other code after narrowing (bad). In this sense, Monkey C is actually safer than TypeScript