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

is default(…) does not explain that the value should be known at compile time #3381

Open
p6rt opened this issue May 6, 2014 · 6 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented May 6, 2014

Migrated from rt.perl.org#121807 (status was 'open')

Searchable as RT121807$

@p6rt
Copy link
Author

p6rt commented May 6, 2014

From @perlpilot

19​:30 <PerlJam> m​: my %h is default(%h<foo>); # surely this is a bug?
19​:30 <+camelia> rakudo-moar 1ccc4d​: OUTPUT«===SORRY!=== Error while
compiling /tmp/HtntR_h3tN�Variable '%h' is not
  declaredâ�¤at /tmp/HtntR_h3tN​:1â�¤------> my %h is
default(%h<foo>�); # surely this is a bug?�
  expecting any of​:â�¤ postfixâ�¤Â»
19​:31 <masak> PerlJam​: yes. it's a bug by the parsing principles of Perl 6,
I would say.
19​:31 <masak> PerlJam​: as in, %h should be defined by that point.
19​:31 <masak> s/defined/declared/
19​:32 <masak> that's why something like this works​:
19​:32 <masak> m​: my %h = %h; say %h
19​:32 <+camelia> rakudo-moar 1ccc4d​: OUTPUT«().hashâ�¤Â»
19​:33 -!- lizmat [~textual@​ip-213-127-250-146.ip.prioritytelecom.net] has
joined #perl6
19​:34 <lizmat> PerlJam​: could you rakudobug that?
19​:34 <retupmoca> oh, that's interesting
19​:34 <retupmoca> m​: my $x = $x.^name; say $x; say $x.^name;
19​:34 <+camelia> rakudo-moar 1ccc4d​: OUTPUT«Anyâ�¤Strâ�¤Â»
19​:35 <jnthn> PerlJam, lizmat​: I think it's 'cus the traits are part of the
declaration...
19​:36 <jnthn> And until we know there's no "is FooType" trait there, we
don't actually know what container to install.
19​:36 -!- lvfjf [~chatzilla@​gateway/tor-sasl/lvfjf] has joined #perl6
19​:36 <jnthn> So it's kinda a can of worms to open.
19​:36 <lizmat> ok... one of those things then...
19​:36 <jnthn> "of" is similar
19​:36 <PerlJam> sure, but the name %h is already in existence, so "Variable
not declared" is LTA

@p6rt
Copy link
Author

p6rt commented Oct 28, 2015

From @usev6

Since rakudo commit 3754356d8e this fails with X​::Syntax​::Variable​::Initializer​:

$ perl6 -e 'my %h = %h; say %h'
===SORRY!=== Error while compiling -e
Cannot use variable %h in declaration to initialize itself
at -e​:1
------> my %h = %�h; say %h
  expecting any of​:
  term

I added a test with commit Raku/roast@a254a271ba

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Oct 28, 2015

From @usev6

Since rakudo commit 3754356d8e this fails with X​::Syntax​::Variable​::Initializer​:

$ perl6 -e 'my %h = %h; say %h'
===SORRY!=== Error while compiling -e
Cannot use variable %h in declaration to initialize itself
at -e​:1
------> my %h = %�h; say %h
  expecting any of​:
  term

I added a test with commit Raku/roast@a254a271ba

I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Oct 28, 2015

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

@p6rt
Copy link
Author

p6rt commented Feb 17, 2017

From @AlexDaniel

Alright, I'm reopening this.

The error message is indeed LTA, it should clearly indicate that the value needs to be known *at compile time*, and perhaps it can somehow explain why %h is not known to be declared at that point.

The new error message doesn't really resolve the issue. In fact, it is arguably even more confusing.

However, the whole idea of using %h<foo> as the default value is not going to work any time soon. It has to be a fixed value that should be known at compile-time. It's not just that %h<foo> doesn't work, anything else is not going to work also (e.g. %someotherhash<foo>).

Well, unless you do something like ï½¢BEGIN my %z; BEGIN %z<foo> = 42ï½£, which is clearly not what was required.

As I'm committing to revert the results of RT #​125371 (which I wholeheartedly believe was a wrong move), the original behavior of ï½¢is default(…)ï½£ will be restored.

On 2015-10-28 14​:46​:32, bartolin@​gmx.de wrote​:

Since rakudo commit 3754356d8e this fails with
X​::Syntax​::Variable​::Initializer​:

$ perl6 -e 'my %h = %h; say %h'
===SORRY!=== Error while compiling -e
Cannot use variable %h in declaration to initialize itself
at -e​:1
------> my %h = %�h; say %h
expecting any of​:
term

I added a test with commit
Raku/roast@a254a271ba

I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Feb 17, 2017

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

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant