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

No error when doing 'is trait' and the trait is missing in Rakudo #4441

Closed
p6rt opened this issue Jul 25, 2015 · 6 comments
Closed

No error when doing 'is trait' and the trait is missing in Rakudo #4441

p6rt opened this issue Jul 25, 2015 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jul 25, 2015

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

Searchable as RT125689$

@p6rt
Copy link
Author

p6rt commented Jul 25, 2015

From @masak

<vendethiel> m​: multi trait_mod​:<is>(Mu​:U $type, :$data!){ say
$type.attributes; say 1 }; class X is data { has $.a; }; say
X.WHAT.perl
<camelia> rakudo-moar cf30a7​: OUTPUT«X␤»
<vendethiel> I'm not sure why my multi isn't picked up?
<masak> m​: class X is data {}
<camelia> rakudo-moar cf30a7​: ( no output )
<moritz> m​: class X is nosuchtrait { }
<camelia> rakudo-moar cf30a7​: ( no output )
<masak> m​: class X is aloogabooga {}
<camelia> rakudo-moar cf30a7​: ( no output )
<moritz> bug!
* masak submits it

<masak> m​: class C is aloogabooga {}
<camelia> rakudo-moar cf30a7​: OUTPUT«===SORRY!=== Error while
compiling /tmp/UXeCmKzq6m␤'C' cannot inherit from 'aloogabooga'
because it is unknown. [...]
<masak> hah!
<masak> this time I caught it before hitting "Send" :P
<masak> people, do *not* use `X` as the name of an "example class"
when testing things on camelia.
<masak> use `A` or `C` or some other letter early in the alphabet.
<masak> I'm still going to submit this, because *something* is wrong, clearly.
<masak> but it involves using `X`.

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

From @peschwa

On Sat Jul 25 03​:26​:01 2015, masak wrote​:

<vendethiel> m​: multi trait_mod​:<is>(Mu​:U $type, :$data!){ say
$type.attributes; say 1 }; class X is data { has $.a; }; say
X.WHAT.perl
<camelia> rakudo-moar cf30a7​: OUTPUT«X␤»
<vendethiel> I'm not sure why my multi isn't picked up?
<masak> m​: class X is data {}
<camelia> rakudo-moar cf30a7​: ( no output )
<moritz> m​: class X is nosuchtrait { }
<camelia> rakudo-moar cf30a7​: ( no output )
<masak> m​: class X is aloogabooga {}
<camelia> rakudo-moar cf30a7​: ( no output )
<moritz> bug!
* masak submits it

<masak> m​: class C is aloogabooga {}
<camelia> rakudo-moar cf30a7​: OUTPUT«===SORRY!=== Error while
compiling /tmp/UXeCmKzq6m␤'C' cannot inherit from 'aloogabooga'
because it is unknown. [...]
<masak> hah!
<masak> this time I caught it before hitting "Send" :P
<masak> people, do *not* use `X` as the name of an "example class"
when testing things on camelia.
<masak> use `A` or `C` or some other letter early in the alphabet.
<masak> I'm still going to submit this, because *something* is wrong,
clearly.
<masak> but it involves using `X`.

Rakudo commit 08d854c fixes this, in what I perceive as a band-aidy way. The commit message has an explanation of my understanding of what happens, duplicated here for ease of access​:

For some reason the lookup with $*W.find_symbol in apply_trait doesn't look for
X​::Inheritance​::UnknownParent but Inheritance​::UnknownParent in 'class X is
nosuchtrait { }', presumably because it happens 'inside' package X. Changing
the lookup to only look inside the setting loops infinitely when compiling the
setting. The empty (but commented) CATCH prevents this.

@p6rt
Copy link
Author

p6rt commented Oct 8, 2015

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

@p6rt
Copy link
Author

p6rt commented Oct 11, 2015

From @niner

The endless loop is a bootstrap issue. It starts with routine_def​:
  if $<onlystar> {
  # Protect with try; won't work when declaring the initial
  # trait_mod proto in CORE.setting!
  try $*W.apply_trait($/, '&trait_mod​:<is>', $*DECLARAND, :onlystar(1));
  }
Like the comment explains, the trait will not be found at this point of compiling the setting, leading to Rakudo trying to find X​::Inheritance​::UnkownParent and failing.
I see two ways for a cleaner fix​:
* avoiding applying the trait when we know it will fail anyway or
* check in the CATCH block if it really is the exact situation that it's meant to fix.

@p6rt
Copy link
Author

p6rt commented Nov 28, 2015

From @jnthn

On Sun Oct 11 03​:11​:45 2015, nine@​detonation.org wrote​:

The endless loop is a bootstrap issue. It starts with routine_def​:
if $<onlystar> {
# Protect with try; won't work when declaring the initial
# trait_mod proto in CORE.setting!
try $*W.apply_trait($/, '&trait_mod​:<is>', $*DECLARAND,
:onlystar(1));
}
Like the comment explains, the trait will not be found at this point
of compiling the setting, leading to Rakudo trying to find
X​::Inheritance​::UnkownParent and failing.
I see two ways for a cleaner fix​:
* avoiding applying the trait when we know it will fail anyway or
* check in the CATCH block if it really is the exact situation that
it's meant to fix.

Or just reorganize the code a bit so the loop can't happen. :-) As to the original issue, I added a test in S12-class/inheritance.t to check that a class X using "is" with some name that does not exist gets the proper exception thrown.

@p6rt p6rt closed this as completed Nov 28, 2015
@p6rt
Copy link
Author

p6rt commented Nov 28, 2015

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

@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