🦋 Welcome to the IRC channel of the core developers of the Raku Programming Language (raku.org #rakulang). This channel is logged for the purpose of history keeping about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Logs available at irclogs.raku.org/raku-dev/live.html | For MoarVM see #moarvm
Set by lizmat on 8 June 2022.
Geth nqp: vrurg++ created pull request #786:
Add support for RakuAST::Origin::Match
01:47
Geth rakudo/rakuast: 4 commits pushed by (Stefan Seifert)++ 09:27
gfldex m: class C { method foo(--> self) {} } 14:29
camelia ===SORRY!=== Error while compiling <tmp>
Type 'self' is not declared
at <tmp>:1
------> class C { method foo(--> self⏏) {} }
gfldex I was under the impression that self is always declared for a method.
Nemokosch that makes sense - and why is it recognized as a "type" anyway 14:33
gfldex m: constant self = 42; class C { method foo(--> self) {} } 14:44
camelia ( no output )
gfldex Also, it should throw X::Syntax::NoSelf. 14:46
Nemokosch so the outer self managed to peek in, although the method defines its own self 14:50
return values are kinda fragile 14:51
sub foo(--> -1) {}
Kaiepi m: role Foo[Mu \T] { method of { T } }; class Bar { method baz(Foo[self] $foo) { $foo.of } }; say Bar.baz: Foo[Bar] 14:53
camelia Type check failed in binding to parameter '$foo'; expected Foo[NQPMu] but got Foo[Bar] (Foo[Bar])
in method baz at <tmp> line 1
in block <unit> at <tmp> line 1
Nemokosch how do function return values work, by the way? 14:56
sub bar(-->1) { 2 }
1 seems to win here
but at the same time, if I wrote -->Int, I wouldn't get the type object back 14:58
(which is desirable but at least not trivial)
[Coke] I believe it's :if it's a type object, any concrete return values must match the type. If it's a concrete value, that's what you get. 16:09
m: sub a(-->3) { return "a" }; say a(); 16:11
camelia ===SORRY!=== Error while compiling <tmp>
No return arguments allowed when return value 3 is already specified in the signature
at <tmp>:1
------> sub a(-->3) { return "a" ⏏}; say a();
[Coke] and also that.