New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix op_if/unless/with/without coercion #383
Conversation
Sample code: ``` my $foo := 42; my int $bar := $foo || 200; say($bar); ``` Before it says '0' and now '42'. The problem is we generate $foo || 200 as - QAST::Op(unless &infix:<||>) || - QAST::Var(lexical $bar) - QAST::IVal(200) and thus $bar only be a condition. If we want to return its value, we forget to coerce its kind. Now this fix only apply on op_unless. If applies on the four ops handled this block, it fails some tests in t/qast/01-qast.t.
No, this break
to say 0. I will work on it. |
Now we generate correct condition IR, it's quite like a copy from JVM backend.
|
(nqp::defined($*WANT) ?? $*WANT !! $MVM_reg_obj)); | ||
$fix_coercion := $coercion; | ||
$regalloc.release_register($res_reg, $res_kind); | ||
$res_reg := $regalloc.fresh_register($coercion.result_kind); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to set the register in $res_reg at runtime instead of overwriting $res_reg at compile time. We might succeed and not do the coercion at all
); | ||
} | ||
|
||
my $fix_coercion; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a variable, just add the coercion when we are checking for the 3 operand form.
Sample code:
Before it says '0' and now '42'.
The problem is we generate $foo || 200 as
and thus $bar only be a condition. If we want to return its value,
we forget to coerce its kind.
Now this fix only apply on op_unless. If applies on the four ops
handled this block, it fails some tests in t/qast/01-qast.t.
For details