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

use of module that defines traits within class scope hides locally defined traits #4818

Open
p6rt opened this issue Dec 4, 2015 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Dec 4, 2015

Migrated from rt.perl.org#126804 (status was 'new')

Searchable as RT126804$

@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

From @jonathanstowe

Hi,
there is, to me anyway, an unexpected change in behaviour between 2015.11-163-g2897239 and 2015.11-347-g47d2daf . If it is expected then I am quite happy to accept that (with the behaviour documented,) but it does look unintended to me.

Given TR.pm​:

module TR {
  multi sub trait_mod​:<is> (Attribute​:D $a, :$some-trait!) is export {
  }
}

And Foo.pm​:

class Foo {
  use TR;
  multi sub trait_mod​:<is> (Attribute $a, :$other-trait) is export {
  }
}

Then "tr"​:

use Foo;

class Womble {
  has $.foo is other-trait;
}

results (in the latter revision)​:

Can't use unknown trait 'is other-trait' in an attribute declaration.
at /home/jonathan/devel/perl6/tr​:4
  expecting any of​:
  rw
  readonly
  box_target
  leading_docs
  trailing_docs

But moving the "use TR;" outside the Foo class block makes the trait from within Foo to be recognised. It works in both ways in the 2015.11-163-g2897239

This does have ecosystem implications (see e.g. tadzik/JSON-Unmarshal#14 ) so if it is actually a conscious change in behaviour (and not an unintended consequence of some other change,) it probably needs to be clearly documented somewhere.

Thanks.

@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

From @jonathanstowe

Just bisected this on rakudo-moar and it appears that​:

87288285f6f398ec7cba0900312ced4b580d79ed is the first bad commit
commit 87288285f6f398ec7cba0900312ced4b580d79ed
Author​: Stefan Seifert <nine@​detonation.org>
Date​: Sat Nov 14 10​:43​:38 2015 +0100

  Have Repository​::FileSystem automatically precompile files
 
  We now precompile loaded modules automatically. However, we cannot do this
  anymore as soon as we encounter a 'use lib' as this changes the precompilation
  store used. Consider​:
  use Test;
  use lib 'foo';
  use Test​::Util; # which again uses Test
  Test​::Util would be loaded from a different precompilation store that contains
  a different precompiled version of Test to the one already loaded.

:040000 040000 67079ac3caa0dea4eab121fa09edfcd14306559c 48e40ca79a4922c6fa912cfd387235e5ddd6f258 M src

Not quite sure where that leaves us.

@p6rt
Copy link
Author

p6rt commented Dec 4, 2015

From @jonathanstowe

It appears (as suggested by nine on IRC,) that changing the 'tr' to​:

use Test;
use lib '.';
use Foo;

class Womble {
  has $.foo is other-trait;
}

and running it without a '-I.' gets rid of the error, this would suggest there may have been a pre-existing pre-compilation problem, that got exposed when everything was precompiled again.

@p6rt
Copy link
Author

p6rt commented Apr 14, 2016

From @jonathanstowe

This is stll present as of Rakudo version 2016.03-110-g5bfc8fb built on MoarVM version 2016.03-104-g10d397

@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