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

Rakudo tries to call role-parameter typename as a sub when using 'does' with a parameterized RHS && missing line# in the error #1194

Closed
p6rt opened this issue Aug 2, 2009 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Aug 2, 2009

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

Searchable as RT68138$

@p6rt
Copy link
Author

p6rt commented Aug 2, 2009

From eternaleye@gmail.com

This code fails. Moritz believes it to be due to T not being bound when
Positional[T] appears. Also, the error has no line number.

role TreeNode[​::T] does Positional[T] {
  has TreeNode[T] @​!children handles 'postcircumfix​:<[ ]>';
  has T $.data is rw;
}
my $tree = TreeNode[Int].new;
$tree.data = 3;
$tree[0] = TreeNode[Int].new;
$tree[1] = TreeNode[Int].new;
$tree[0].data = 1;
$tree[1].data = 4;
.say for $tree.data, $tree[0,1]>>.data;

@p6rt
Copy link
Author

p6rt commented Jun 30, 2012

From @coke

On Sun Aug 02 14​:02​:30 2009, eternaleye@​gmail.com wrote​:

This code fails. Moritz believes it to be due to T not being bound when
Positional[T] appears. Also, the error has no line number.

role TreeNode[​::T] does Positional[T] {
has TreeNode[T] @​!children handles 'postcircumfix​:<[ ]>';
has T $.data is rw;
}
my $tree = TreeNode[Int].new;
$tree.data = 3;
$tree[0] = TreeNode[Int].new;
$tree[1] = TreeNode[Int].new;
$tree[0].data = 1;
$tree[1].data = 4;
.say for $tree.data, $tree[0,1]>>.data;

Current failure mode is​:

Cannot call a method on type variable T
  in any find_method at src/gen/Metamodel.pm​:282
  in <anon> at src/gen/Metamodel.pm​:1614
  in <anon> at src/gen/Metamodel.pm​:1610
  in any accepts_type at src/gen/Metamodel.pm​:1608
  in method at_pos at src/gen/CORE.setting​:5858
  in method at_pos at src/gen/CORE.setting​:1252
  in method postcircumfix​:<[ ]> at src/gen/CORE.setting​:1211
  in method postcircumfix​:<[ ]> at src/gen/CORE.setting​:196
  in block <anon> at foo.pl​:7

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Jun 30, 2012

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

@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @usev6

The error has changed (same output on MoarVM and JVM)​:

Cannot modify an immutable TreeNode[Int]
  in method assign_pos at src/gen/m-CORE.setting​:2103
  in sub postcircumfix​:<[ ]> at src/gen/m-CORE.setting​:3307
  in block <unit> at 68138.p6​:7

1 similar comment
@p6rt
Copy link
Author

p6rt commented Mar 1, 2015

From @usev6

The error has changed (same output on MoarVM and JVM)​:

Cannot modify an immutable TreeNode[Int]
  in method assign_pos at src/gen/m-CORE.setting​:2103
  in sub postcircumfix​:<[ ]> at src/gen/m-CORE.setting​:3307
  in block <unit> at 68138.p6​:7

@p6rt
Copy link
Author

p6rt commented Mar 2, 2015

From @Mouq

The new failure condition is due to the transfer of postcircumfix​:<[ ]> from methods to subs. The correct way to write the @​children attribute is now​: has TreeNode[T] @​!children handles <at_pos assign_pos bind_pos>;

With this change, it works​:
$ perl6 -e'role TreeNode[​::T] does Positional[T] { has TreeNode[T] @​!children handles <at_pos assign_pos bind_pos>; has T $.data is rw; }; my $tree = TreeNode[Int].new; $tree.data = 3; $tree[0] = TreeNode[Int].new; $tree[1] = TreeNode[Int].new; $tree[0].data = 1; $tree[1].data = 4; .say for $tree.data, $tree[0,1]>>.data;'
3
1
4

Marking as testneeded :)

On Sun Mar 01 11​:40​:54 2015, bartolin@​gmx.de wrote​:

The error has changed (same output on MoarVM and JVM)​:

Cannot modify an immutable TreeNode[Int]
in method assign_pos at src/gen/m-CORE.setting​:2103
in sub postcircumfix​:<[ ]> at src/gen/m-CORE.setting​:3307
in block <unit> at 68138.p6​:7

@p6rt
Copy link
Author

p6rt commented Apr 13, 2015

From @usev6

There was already a (skipped) test in S14-roles/parameterized-type.t. I adjusted the test to use '@​!children handles <at_pos assign_pos bind_pos>' as Mouq++ pointed out​:
Raku/roast@223db17d80

I'm closing this ticket as 'resolved'.

1 similar comment
@p6rt
Copy link
Author

p6rt commented Apr 13, 2015

From @usev6

There was already a (skipped) test in S14-roles/parameterized-type.t. I adjusted the test to use '@​!children handles <at_pos assign_pos bind_pos>' as Mouq++ pointed out​:
Raku/roast@223db17d80

I'm closing this ticket as 'resolved'.

@p6rt
Copy link
Author

p6rt commented Apr 13, 2015

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant