Closed jzakiya closed 6 days ago
Here's a gist file of all the code to compile to produce the error.
https://gist.github.com/jzakiya/11607c333f6cec2207c348b58535d7d5
The compiler is technically right here. There's a few things going on, but I don't really think this is a compiler bug at least. Adding method parameter and return type restrictions makes the problem more clear.
loop do
creates its own scope within the block, so the compiler has to handle the case where it doesn't execute I guess, using while true
does not suffer from this and works just fine.p
is basically conflicting with the ::p()
method which returns the arguments passed to it, and since its only assigned in the loop do
, if that doesn't execute the compiler will call ::p()
with no arguments so it returns an empty tuple, which without a type restriction on the method or n
parameter, is allowed to pass thru, turning the type of n
in to Tuple() | UInt64
.Closing as I don't think there's any real compiler bug here.
This compiles fine.
Then I changed the code to this:
And now get this error.
When I change the order of those 2 terms it still points to the first n.
This has to be a compiler error, right?