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

Smartmatch and type checks fail when using MOP-created class as attribute #2607

Open
Altai-man opened this Issue Jan 13, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@Altai-man
Copy link
Contributor

Altai-man commented Jan 13, 2019

The Problem

my $inner = Metamodel::ClassHOW.new_type(name => 'Inner');
$inner.^compose;

my $outer = Metamodel::ClassHOW.new_type(name => 'Outer');
my $attr = Attribute.new(name => '$!inner', type => $inner, package => $outer, :has_accessor);
$outer.^add_attribute($attr);
$outer.^compose;

say $inner.WHICH eq $outer.^attributes[0].type.WHICH; # True
say $inner === $outer.^attributes[0].type; # True
say $inner ~~ $outer.^attributes[0].type; # False ???

# Type check failed in assignment to $!inner; expected Inner but got Inner.new ???
say $outer.new(inner => $inner.new);

Expected Behavior

For smartmatch to be True and for type check to be passed.

Actual Behavior

Smartmatch fails and type check fails too.

Steps to Reproduce

Run the code above.

Environment

  • Operating system: gnu/linux
  • Compiler version (perl6 -v): This is Rakudo version 2018.12 built on MoarVM version 2018.12
@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 13, 2019

This is because there's a decont missing in the metamodel: if you bind to $attr it works as expected.

Testing a fix now

@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 13, 2019

Fixed with bf0dbbe

@lizmat lizmat added the tests needed label Jan 13, 2019

@lizmat

This comment has been minimized.

Copy link
Contributor

lizmat commented Jan 18, 2019

Not sure where tests for this should live. In roast? or in rakudo? @jnthn?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.