Skip to content
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

Optimizer too greedy when "is rw" in play #4736

Closed
p6rt opened this issue Nov 7, 2015 · 4 comments
Closed

Optimizer too greedy when "is rw" in play #4736

p6rt opened this issue Nov 7, 2015 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Nov 7, 2015

Migrated from rt.perl.org#126585 (status was 'resolved')

Searchable as RT126585$

@p6rt
Copy link
Author

p6rt commented Nov 7, 2015

From @lizmat

[21​:55​:53] <lizmat> m​: sub a($x is rw) { $x; }; a 42 # dies as expected
[21​:55​:54] <+camelia> rakudo-moar 8b834c​: OUTPUT«Parameter '$x' expected a writable container, but got Int value␤ in sub a at /tmp/2NK1Hbv1Ub​:1␤ in block <unit> at /tmp/2NK1Hbv1Ub​:1␤␤»
[21​:56​:11] <lizmat> m​: sub a($x is rw) { $x; }; { a 42 }() # but not if within a block ?
[21​:56​:11] <+camelia> rakudo-moar 8b834c​: ( no output )
[21​:58​:08] <lizmat> m​: sub a($x is rw) { $x; }; { a 42 } # seems to be optimizer related
[21​:58​:08] <+camelia> rakudo-moar 8b834c​: ( no output )
[21​:58​:19] <lizmat> $ perl6 --optimize=off -e 'sub a($x is rw) { $x }; { a 42 }'
[21​:58​:19] <lizmat> Parameter '$x' expected a writable container, but got Int value

@p6rt
Copy link
Author

p6rt commented Nov 8, 2015

From @peschwa

On Sat Nov 07 12​:59​:32 2015, elizabeth wrote​:

[21​:55​:53] <lizmat> m​: sub a($x is rw) { $x; }; a 42 # dies as
expected
[21​:55​:54] <+camelia> rakudo-moar 8b834c​: OUTPUT«Parameter '$x'
expected a writable container, but got Int value␤ in sub a at
/tmp/2NK1Hbv1Ub​:1␤ in block <unit> at /tmp/2NK1Hbv1Ub​:1␤␤»
[21​:56​:11] <lizmat> m​: sub a($x is rw) { $x; }; { a 42 }() # but
not if within a block ?
[21​:56​:11] <+camelia> rakudo-moar 8b834c​: ( no output )
[21​:58​:08] <lizmat> m​: sub a($x is rw) { $x; }; { a 42 } # seems
to be optimizer related
[21​:58​:08] <+camelia> rakudo-moar 8b834c​: ( no output )
[21​:58​:19] <lizmat> $ perl6 --optimize=off -e 'sub a($x is rw) {
$x }; { a 42 }'
[21​:58​:19] <lizmat> Parameter '$x' expected a writable container,
but got Int value

My previous fix for a related issue (in commit 76391ca9) was apparently bogus. I've reverted that in 8b0d257 and implemented the necessary logic (hopefully) correctly in b1a465c. The test in S06-traits/misc.t passes again (and I'll unfudge it after this comment) and camelia shows the correct behavior as well​:

16​:13 <psch> m​: sub a($x is rw) { $x; }; a 42
16​:13 <camelia> rakudo-moar b1a465​: OUTPUT«Parameter '$x' expected a writable container, but got Int value␤ in sub a at /tmp/iAUHG8Hg4F​:1␤ in
  block <unit> at /tmp/iAUHG8Hg4F​:1␤␤»
16​:13 <psch> m​: sub a($x is rw) { $x; }; { a 42 }()
16​:13 <camelia> rakudo-moar b1a465​: OUTPUT«Parameter '$x' expected a writable container, but got Int value␤ in sub a at /tmp/zX2zZQDT2u​:1␤ in
  block <unit> at /tmp/zX2zZQDT2u​:1␤␤»

@p6rt
Copy link
Author

p6rt commented Nov 8, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Mar 12, 2016
@p6rt
Copy link
Author

p6rt commented Mar 12, 2016

@moritz - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant