You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#11145 introduced a new compiler error when the target size in 1-to-n assignments don't match up.
That triggers when the assigned tuples has more elements than the number of targets:
a, b = {1, 2, 3} # Error: cannot assign Tuple(Int32, Int32, Int32) to 2 targets
When the assigned tuple has less elements than the number of targets, a similar error would be expected. But you get a different one:
a, b, c = {1, 2} # Error: index out of bounds for Tuple(Int32, Int32) (2 not in -2..1)
The expected error as per the introducing PR would be this:
a, b, c = {1, 2} # Error: cannot assign Tuple(Int32, Int32) to 3 targets
The reason is that the error specific to multi assign mismatch is triggered in CleanupTransformer, but before the compiler gets there, the expanded code already triggers the index error for accessing an out of range tuple element.
I'm not sure why this wasn't done properly. Maybe it was too complex? The initial PR already has a spec for this, but it's marked as pending.
This isn't a big issue. The important part is that there's a compiler error, it could just be more specific.
#11145 introduced a new compiler error when the target size in 1-to-n assignments don't match up.
That triggers when the assigned tuples has more elements than the number of targets:
When the assigned tuple has less elements than the number of targets, a similar error would be expected. But you get a different one:
The expected error as per the introducing PR would be this:
The reason is that the error specific to multi assign mismatch is triggered in
CleanupTransformer
, but before the compiler gets there, the expanded code already triggers the index error for accessing an out of range tuple element.I'm not sure why this wasn't done properly. Maybe it was too complex? The initial PR already has a spec for this, but it's marked as pending.
This isn't a big issue. The important part is that there's a compiler error, it could just be more specific.
/cc @HertzDevil
The text was updated successfully, but these errors were encountered: