Irrefutable match optimization binding issues
edusporto opened this issue · 0 comments
edusporto commented
Reproducing the behavior
The irrefutable match optimization breaks any match expression not inside of a lambda. For example:
l = 1001
v1 = match l {
x: x
}
v2 = match l {
x: l
}
v3 = match [] {
x: 2002
}
v4 = match l = 3003 {
x: x
y: 0
}
v5 = match p = 4004 with b = 5005 {
x: b
}
main = (v1, v2, v3, v4, v5)
All of these should run correctly and output Result: (1001, (1001, (2002, (3003, 5005))))
, but instead we get the following errors:
Errors:
In definition 'v1':
Unbound variable 'l'.
In definition 'v2':
Unbound variable 'l'.
Unbound variable 'l'.
In definition 'v3':
Unbound variable '%arg'.
In definition 'v4':
Unbound variable 'l'.
In definition 'v5':
Unbound variable 'p'.
Unbound variable 'b'.
The cause for this is the optimization substitutes the match
expression with its first arm directly, without dealing with variable bindings.
System Settings
Every system
Additional context
No response