# New Ticket Created by Elizabeth Mattijsen
# Please include the string: [perl #122253]
# in the subject line of all future correspondence about this issue.
# <URL: https://rt.perl.org/Ticket/Display.html?id=122253 >
[13:33:31] <lizmat> m: class A { has $.a = "a"; method b {
"aaa".subst(/$!a/,"b") }}; say A.new.a; say A.new.b # why isn't the .subst
working ?
[13:33:32] <+camelia> rakudo-moar 41574a: OUTPUT«aaaa»
[13:34:31] <lizmat> m: class A { has $.a = "a"; method b { my $x = $!a;
"aaa".subst(/$x/,"b") }}; say A.new.b # putting it into a lexical first works
[13:34:33] <+camelia> rakudo-moar 41574a: OUTPUT«baa»
[13:34:50] <lizmat> rakudobug?
[13:35:55] <lizmat> FROGGS, jnthn: ^^^
[13:36:47] <jnthn> m: /$!foo/
[13:36:48] <+camelia> rakudo-moar 41574a:
OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling
/tmp/GrGGxT5ir_Variable $!foo used where no 'self' is availableat
/tmp/GrGGxT5ir_:1------> [32m/$!foo[33m⏏[31m/[0m»
[13:36:56] <FROGGS> m: class A { has $.a = "a"; method b {
"aaa".subst(/"$!a"/,"b") }}; say A.new.a; say A.new.b
[13:36:57] <+camelia> rakudo-moar 41574a: OUTPUT«ause of uninitialized
value of type Any in string contextbaaa»
[13:37:21] <FROGGS> that seems to be the runtime lexpad problem thingy
masak++ had described in his blög
[13:37:35] <jnthn> Um
[13:37:38] <Ven> class variables are in lexpads ?
[13:37:49] <jnthn> Wait...a regex is method-ish, and has its own self...
[13:37:56] <FROGGS> eww
[13:38:16] <FROGGS> m: class A { has $.a = "a"; method b {
"aaa".subst($!a,"b") }}; say A.new.a; say A.new.b
[13:38:17] <lizmat> aha... the plot thickens... rakudobug it ?
[13:38:18] <+camelia> rakudo-moar 41574a: OUTPUT«abaa»
[13:38:24] <FROGGS> yeah
[13:38:28] <FROGGS> jnthn: is right
[13:38:56] <jnthn> lizmat: Um, at this point all we have is "it looks
odd" rather than "it should do X"
[13:38:59] <FROGGS> m: class A { has $.a = "a"; method b {
"aaa".subst(/{say self}/,"b") }}; say A.new.a; say A.new.b
[13:39:02] <+camelia> rakudo-moar 41574a: OUTPUT«aA.new(a => "a")baaa»
[13:39:16] <FROGGS> I have no idea
[13:39:25] <FROGGS> m: class A { has $.a = "a"; method b {
"aaa".subst(/"{say self}"/,"b") }}; say A.new.a; say A.new.b
[13:39:27] <+camelia> rakudo-moar 41574a: OUTPUT«aA.new(a => "a")A.new(a
=> "a")A.new(a => "a")A.new(a => "a")aaa»
[13:40:02] <jnthn> m: class A { has $.a = "a"; method b {
"aaa".subst(/:my $ = say $!a; ./, b') } }; A.new.b
[13:40:04] <+camelia> rakudo-moar 41574a:
OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling
/tmp/TCkwyckpg_Unable to parse expression in argument list; couldn't find
final ')' at /tmp/TCkwyckpg_:1------> [32m b { "aaa".subst(/:my $ = say $!a;
./, b[33m⏏[31m') } }; A.new.b[0m …»
[13:40:13] <jnthn> m: class A { has $.a = "a"; method b {
"aaa".subst(/:my $ = say $!a; ./, 'b') } }; A.new.b
[13:40:15] <+camelia> rakudo-moar 41574a: OUTPUT«(Any)»
[13:40:42] <lizmat> m: say "aaa".subst(/a$/,"b") # the reason I ran into
this
[13:40:43] <+camelia> rakudo-moar 41574a: OUTPUT«aab»
[13:40:51] <jnthn> m: class A { has $.a = "a"; method b {
"aaa".subst(/:my $ = say self.WHICH; ./, 'b') } }; A.new.b
[13:40:54] <+camelia> rakudo-moar 41574a: OUTPUT«Cursor|139834212483800»
[13:42:13] <jnthn> m: class A { has $.a = "a"; method b {
"aaa".subst(/:my $ = say self.WHICH, $!a; ./, 'b') } }; A.new.b
[13:42:15] <+camelia> rakudo-moar 41574a:
OUTPUT«Cursor|139900812459976(Any)»
[13:42:21] <jnthn> m: class A { has $.a = "a"; method b {
"aaa".subst(/:my $ = say self.WHICH, $!pos; ./, 'b') } }; A.new.b
[13:42:22] <+camelia> rakudo-moar 41574a:
OUTPUT«[31m===[0mSORRY![31m===[0m Error while compiling
/tmp/DBWEyB7Zo2Attribute $!pos not declared in class Aat
/tmp/DBWEyB7Zo2:1------> [32m $ = say self.WHICH, $!pos; ./, 'b') }
}[33m⏏[31m; A.new.b[0m expecting any of: postfi…»
[13:42:51] <jnthn> m: class A { has $!dummy; has $.a = "a"; method b {
"aaa".subst(/:my $ = say self.WHICH, $!a; ./, 'b') } }; A.new.b
[13:42:53] <+camelia> rakudo-moar 41574a:
OUTPUT«Cursor|140307760568368Cursor|140307760671904No such method 'gist' for
invocant of type 'ParseShared' in sub say at src/gen/m-CORE.setting:13805
in method match at src/gen/m-CORE.setting:6280 in method subst at
src/gen/m-CORE.setting:6355 in…»
[13:42:59] <jnthn> Wow.
[13:43:22] <jnthn> Yes, that's quite a mis-compile.
[13:43:36] <jnthn> I know what it's doing.
[13:43:47] <jnthn> I don't know we can make it DWLM though...
[13:43:57] <jnthn> Because self in a /.../ thing really is Cursor
[13:44:13] <FROGGS> L is for lizmat? :o)
[13:44:17] <jnthn> Yes.
[13:44:27] <FROGGS> true... and in a code somebody might really want the
Cursor
[13:44:34] <jnthn> Right
[13:44:35] <lizmat> ok
[13:44:40] <jnthn> Well, it's clearer with tokens and so forth.
[13:44:56] <jnthn> All the same, we shouldn't compile it to stuff that
looks up a random attribute on the wrong object. :)
[13:45:29] <lizmat> I guess it should at least complain about it being an
attribute that doesn't exist on the Regex ?
[13:45:38] <jnthn> lizmat: Yeah.
[13:45:44] <lizmat> so rakudobug it ?
[13:45:55] <jnthn> Should just not compile
[13:46:06] <jnthn> Yes, now we know the expected behavior, it's a
resolvable ticket :)
[13:46:14] <jnthn> So go for it :)