Navigation Menu

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

Cannot assign to an undeclared dynamic variable in Rakudo #1497

Closed
p6rt opened this issue Feb 15, 2010 · 9 comments
Closed

Cannot assign to an undeclared dynamic variable in Rakudo #1497

p6rt opened this issue Feb 15, 2010 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Feb 15, 2010

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

Searchable as RT72816$

@p6rt
Copy link
Author

p6rt commented Feb 15, 2010

From @masak

<masak> rakudo​: my $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Int()␤»
<masak> rakudo​: $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly value␤current
instr. '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»
* masak submits rakudobug
<masak> rakudo​: $*x = 42
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly value␤current
instr.​: '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»

I'm not sure dynamic variables can be assigned to without first being
initialized. I skimmed S02 but didn't find anything mentioning it.
Anyway, either you can and the error shouldn't be there, or you can't
and the error is less than awesome.

@p6rt
Copy link
Author

p6rt commented Feb 27, 2010

From @pmichaud

An undeclared dynamic variable currently results in a failure;
attempting to assign to that failure produces the readonly message.

Perhaps assignment to a failure should throw its exception?

Pm

@p6rt
Copy link
Author

p6rt commented Feb 27, 2010

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

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

From @coke

On Mon Feb 15 00​:53​:39 2010, masak wrote​:

<masak> rakudo​: my $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Int()␤»
<masak> rakudo​: $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly value␤current
instr. '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»
* masak submits rakudobug
<masak> rakudo​: $*x = 42
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly value␤current
instr.​: '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»

I'm not sure dynamic variables can be assigned to without first being
initialized. I skimmed S02 but didn't find anything mentioning it.
Anyway, either you can and the error shouldn't be there, or you can't
and the error is less than awesome.

Now says​:

23​:34 < [Coke]> rakudo​: $*x = 42; say $*x.WHAT
23​:34 <+p6eval> rakudo cbdd9b​: OUTPUT«Cannot assign to a non-container␤ in <anon>
  at /tmp/meGTbjLflb​:1␤ in <anon> at /tmp/meGTbjLflb​:1␤␤»

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 20, 2011

From @coke

On Mon Sep 19 20​:34​:36 2011, coke wrote​:

On Mon Feb 15 00​:53​:39 2010, masak wrote​:

<masak> rakudo​: my $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Int()␤»
<masak> rakudo​: $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly
value␤current
instr. '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»
* masak submits rakudobug
<masak> rakudo​: $*x = 42
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly
value␤current
instr.​: '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»

I'm not sure dynamic variables can be assigned to without first
being
initialized. I skimmed S02 but didn't find anything mentioning it.
Anyway, either you can and the error shouldn't be there, or you
can't
and the error is less than awesome.

Now says​:

23​:34 < [Coke]> rakudo​: $*x = 42; say $*x.WHAT
23​:34 <+p6eval> rakudo cbdd9b​: OUTPUT«Cannot assign to a non-
container␤ in <anon>
at /tmp/meGTbjLflb​:1␤ in <anon> at
/tmp/meGTbjLflb​:1␤␤»

(self-reply-to-add-cc-I-forgot)
--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented May 29, 2012

From @diakopter

On Mon Sep 19 20​:34​:36 2011, coke wrote​:

On Mon Feb 15 00​:53​:39 2010, masak wrote​:

<masak> rakudo​: my $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Int()␤»
<masak> rakudo​: $*x = 42; say $*x.WHAT
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly
value␤current
instr. '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»
* masak submits rakudobug
<masak> rakudo​: $*x = 42
<p6eval> rakudo 70667a​: OUTPUT«Cannot assign to readonly
value␤current
instr.​: '&infix​:<=>' pc 15648 (src/builtins/Junction.pir​:169)␤»

I'm not sure dynamic variables can be assigned to without first
being
initialized. I skimmed S02 but didn't find anything mentioning it.
Anyway, either you can and the error shouldn't be there, or you
can't
and the error is less than awesome.

Now says​:

23​:34 < [Coke]> rakudo​: $*x = 42; say $*x.WHAT
23​:34 <+p6eval> rakudo cbdd9b​: OUTPUT«Cannot assign to a non-
container␤ in <anon>
at /tmp/meGTbjLflb​:1␤ in <anon> at
/tmp/meGTbjLflb​:1␤␤»

Now says​:

14​:52 < diakopter> p6​: $*x = 42; say $*x.WHAT
14​:52 <+p6eval> rakudo 223419​: OUTPUT«Dynamic variable $*x not found␤
in method <anon> at
  src/gen/CORE.setting​:9317␤ in <anon> at
src/gen/Metamodel.pm​:2260␤ in any
  find_method_fallback at src/gen/Metamodel.pm​:2258␤ in
any find_method at
  src/gen/Metamodel.pm​:828␤ in block <anon> at
/tmp/Ivt9zr6xSI​:…
14​:52 <+p6eval> ..pugs​: OUTPUT«Int␤»
14​:52 <+p6eval> ..niecza v18-1-gc86e3f0​: OUTPUT«Unhandled exception​:
Writing to readonly
  scalar␤ at /tmp/qSIatGUdIf line 1 (mainline @​ 2) ␤
at
  /home/p6eval/niecza/lib/CORE.setting line 3910 (ANON @​
3) ␤ at
  /home/p6eval/niecza/lib/CORE.setting line 3911 (module-
CORE @​ 558) ␤ at
  /home/p6eval/niecza/lib…
14​:52 < diakopter> p6​: $*x = 42;
14​:52 <+p6eval> rakudo 223419​: OUTPUT«Dynamic variable $*x not found␤
in method <anon> at
  src/gen/CORE.setting​:9317␤ in <anon> at
src/gen/Metamodel.pm​:2260␤ in any
  find_method_fallback at src/gen/Metamodel.pm​:2258␤ in
any find_method at
  src/gen/Metamodel.pm​:828␤ in block <anon> at
/tmp/Vhay3VPmpQ​:…
14​:52 <+p6eval> ..niecza v18-1-gc86e3f0​: OUTPUT«Unhandled exception​:
Writing to readonly
  scalar␤ at /tmp/EGuxWILmSp line 1 (mainline @​ 2) ␤
at
  /home/p6eval/niecza/lib/CORE.setting line 3910 (ANON @​
3) ␤ at
  /home/p6eval/niecza/lib/CORE.setting line 3911 (module-
CORE @​ 558) ␤ at
  /home/p6eval/niecza/lib…

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

From @usev6

Assignment to an undeclared dynamic variable fails now with a typed exception "X​::Dynamic​::NotFound" and an adequate error message​:

$ perl6 -e '$*x = 42'
Dynamic variable $*x not found
  in method <anon> at src/gen/m-CORE.setting​:14595
  in any find_method_fallback at src/gen/m-Metamodel.nqp​:2741
  in any find_method at src/gen/m-Metamodel.nqp​:988
  in block <unit> at -e​:1

There is a (passing) test in S32-exceptions/misc.t -- added with commit Raku/roast@5cea4946ce

I'm closing this ticket now.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

From @usev6

Assignment to an undeclared dynamic variable fails now with a typed exception "X​::Dynamic​::NotFound" and an adequate error message​:

$ perl6 -e '$*x = 42'
Dynamic variable $*x not found
  in method <anon> at src/gen/m-CORE.setting​:14595
  in any find_method_fallback at src/gen/m-Metamodel.nqp​:2741
  in any find_method at src/gen/m-Metamodel.nqp​:988
  in block <unit> at -e​:1

There is a (passing) test in S32-exceptions/misc.t -- added with commit Raku/roast@5cea4946ce

I'm closing this ticket now.

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

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

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

No branches or pull requests

1 participant