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

Using attribute variables outside of methods causes strange errors in rakudo #193

Closed
p6rt opened this issue Jul 27, 2008 · 6 comments
Closed
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 27, 2008

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

Searchable as RT57336$

@p6rt
Copy link
Author

p6rt commented Jul 27, 2008

From @masak

This works...

$ ./perl6 -e 'class A { my $.a; method m { say $.a } }'

...and this...

$ ./perl6 -e 'class A { has $!a; method m { say $!a } }'

...but not this...

$ perl6 -e 'say $.a'
error​:imcc​:syntax error, unexpected '\n', expecting '('
  in file 'EVAL_13' line 11
Could not find non-existent sub self
current instr.​: '_block11' pc 11 (EVAL_13​:11)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 806
(src/PCT/HLLCompiler.pir​:481)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 14567 (perl6.pir​:172)

...nor this...

$ perl6 -e 'say $!a'
The opcode 'getattribute_p_ic_sc' (getattribute<3>) was not found.
Check the type and number of the arguments
current instr.​: 'parrot;PCT​::HLLCompiler;evalpmc' pc 744
(src/PCT/HLLCompiler.pir​:448)
called from Sub 'parrot;PCT​::HLLCompiler;compile' pc 438
(src/PCT/HLLCompiler.pir​:303)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 776
(src/PCT/HLLCompiler.pir​:473)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 14567 (perl6.pir​:172)

(Granted, they should throw errors, but errors related to using
attribute syntax outside of a class definition.)

This one could be made to work, but currently doesn't​:

$ perl6 -e 'class A { my $.a; say $.a }'
error​:imcc​:syntax error, unexpected '\n', expecting '('
  in file 'EVAL_13' line 27
Could not find non-existent sub self
current instr.​: 'parrot;A;_block22' pc 36 (EVAL_13​:27)
called from Sub 'parrot;A;_block21' pc 25 (EVAL_13​:18)
called from Sub 'parrot;PCT​::HLLCompiler;evalpmc' pc 744
(src/PCT/HLLCompiler.pir​:448)
called from Sub 'parrot;PCT​::HLLCompiler;compile' pc 438
(src/PCT/HLLCompiler.pir​:303)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 776
(src/PCT/HLLCompiler.pir​:473)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 14567 (perl6.pir​:172)
perl6(27093) malloc​: *** error for object 0x279c820​: double free
*** set a breakpoint in malloc_error_break to debug
Segmentation fault

This one probably shouldn't work, but it shouldn't segfault either​:

$ ./perl6 -e 'class A { has $.a; say $.a }'
error​:imcc​:syntax error, unexpected '\n', expecting '('
  in file 'EVAL_13' line 25
Could not find non-existent sub self
current instr.​: 'parrot;A;_block23' pc 33 (EVAL_13​:25)
called from Sub 'parrot;A;_block22' pc 25 (EVAL_13​:18)
called from Sub 'parrot;PCT​::HLLCompiler;evalpmc' pc 744
(src/PCT/HLLCompiler.pir​:448)
called from Sub 'parrot;PCT​::HLLCompiler;compile' pc 438
(src/PCT/HLLCompiler.pir​:303)
called from Sub 'parrot;PCT​::HLLCompiler;eval' pc 776
(src/PCT/HLLCompiler.pir​:473)
called from Sub 'parrot;PCT​::HLLCompiler;command_line' pc 1305
(src/PCT/HLLCompiler.pir​:708)
called from Sub 'parrot;Perl6​::Compiler;main' pc 14567 (perl6.pir​:172)
perl6(27084) malloc​: *** error for object 0x27c9640​: double free
*** set a breakpoint in malloc_error_break to debug
Segmentation fault

@p6rt
Copy link
Author

p6rt commented Jul 29, 2008

From @jnthn

Hi,

I've made some of these fail a little less spectacularly now.
Implementing a better error message cleanly either needs some
refactoring of variable declaration handling code (so when we're parsing
a variable we know if we're parsing a declaration), or is something we
should do in an analysis stage once we already have the syntax tree (but
we've not got the infrastructure for that yet).

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 29, 2008

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

@p6rt
Copy link
Author

p6rt commented Apr 27, 2009

From @ronaldxs

Well it's now more than half a year later and the current behavior is​:

PhatEddy rakudo​: say $.a
17​:22 p6eval rakudo 6f1649​: OUTPUT«Lexical 'self' not found␤current
instr.​: '_block14' pc 51 (EVAL_17​:34)␤»

It seems to me that if you try to access an attribute with no
applicable class or object, then complaining that there is
no "Lexical 'self'" might be reasonable.

Wondering if it may be OK to resolve the ticket.

@p6rt
Copy link
Author

p6rt commented Sep 7, 2009

From @masak

I think it's OK to resolve this ticket. Doing so.

@p6rt
Copy link
Author

p6rt commented Sep 7, 2009

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

@p6rt p6rt closed this as completed Sep 7, 2009
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant