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

WHAT() (when called as a subroutine) gives odd results in Rakudo #1370

Closed
p6rt opened this issue Oct 20, 2009 · 5 comments
Closed

WHAT() (when called as a subroutine) gives odd results in Rakudo #1370

p6rt opened this issue Oct 20, 2009 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 20, 2009

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

Searchable as RT69915$

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

From @masak

<moritz_> rakudo​: sub f1 ($a, $b) { WHAT($a) ~ WHAT($b) }; say f1(a => 42, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Str()␤»
<moritz_> wtf?
<moritz_> rakudo​: sub f1 ($a, $b) { $a.WHAT ~ $b.WHAT }; say f1(a => 42, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Int()Int()␤»
<masak> what happened there in the first one?
<moritz_> I have no idea.
<moritz_> masak​: care to submit? :-)
* masak submits
* jnthn back
<mathw> jnthn​: just as moritz_ finds you another exciting bug
<jnthn> uh, wtf
<p6eval> rakudo 1ab069​: OUTPUT«Int()Int()␤»
<jnthn> Why on earth would it matter that one is a Str and the other not?
<moritz_> and it's only one Str()
<moritz_> rakudo​: sub f1 ($a, $b) { $a.WHAT ~ $b.WHAT }; say f1(​:a, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Int()Int()␤»
<moritz_> oh.
<jnthn> Yup, should be Bool()Int() there.
<jnthn> rakudo​: sub f1 ($a, $b) { WHAT($a) ~ WHAT($b) }; say f1(a => 42, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Str()␤»
<jnthn> rakudo​: sub f1 ($a, $b) { WHAT($a) ~ WHAT($b) }; say f1(23, a => 42)
<p6eval> rakudo 1ab069​: OUTPUT«Str()␤»
<moritz_> rakudo​: sub f1 ($a, $b) { WHAT($a).perl ~ ' ' ~
WHAT($b).perl }; say f1(23, a => 42)
<p6eval> rakudo 1ab069​: OUTPUT«Str()␤»
<moritz_> parsing bug with WHAT()?
<jnthn> rakudo​: my $a = 42; my $b = 23; say WHAT($a) ~ WHAT($b)
<p6eval> rakudo 1ab069​: OUTPUT«Str()␤»
<moritz_> rakudo​: sub w($x) { $x.WHAT }; sub f1 ($a, $b) { w($a) ~
w($b) }; say f1(a => 42, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Int()Int()␤»
<moritz_> yep
<jnthn> moritz_​: It's nothing to do with calling, it seems.
<moritz_> rakudo​: sub w($x) { WHAT($x) }; sub f1 ($a, $b) { w($a) ~
w($b) }; say f1(a => 42, 23)
<p6eval> rakudo 1ab069​: OUTPUT«Int()Int()␤»
<moritz_> jnthn​: my bet is parsing issues with WHAT()

@p6rt
Copy link
Author

p6rt commented Oct 21, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S12-methods/what.t

commit b39906abb54f5c227e39afe5100ad41ba8ae60fc
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Wed Oct 21 18​:29​:07 2009 +0000

  [t/spec] Tests for RT #​69915
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28873 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S12-methods/what.t b/t/spec/S12-methods/what.t
index d04c6b0..a9cf632 100644
--- a/t/spec/S12-methods/what.t
+++ b/t/spec/S12-methods/what.t
@@ -1,6 +1,6 @@
 use v6;
-
 use Test;
+plan *;
 
 =begin pod
 
@@ -12,8 +12,6 @@ This test tests the C<WHAT> builtin.
 
 # L<S12/Introspection/"WHAT">
 
-plan 15;
-
 # Basic subroutine/method form tests for C<WHAT>.
 {
   my $a = 3;
@@ -67,4 +65,29 @@ plan 15;
     ok &infix:<+>.WHAT ~~ Multi, '.WHAT of built-in infix op is Multi';
 }
 
+# RT #69915
+{
+    sub rt69915f( $a, $b ) { return WHAT($a) ~ '~' ~ WHAT($b) }
+    sub rt69915m( $a, $b ) { return $a.WHAT  ~ '~' ~ $b.WHAT  }
+
+    is rt69915m( a => 42, 23 ), 'Int()~Int()', 'WHAT method on ints';
+
+    #?rakudo 4 todo 'RT 69915'
+    is rt69915f( a => 42, 23 ), 'Int()~Int()', 'WHAT function on ints (1)';
+    is rt69915f( 23, a => 42 ), 'Int()~Int()', 'WHAT function on ints (2)';
+
+    is rt69915f( :a, 23 ), 'Bool()~Int()', 'WHAT function on bool and int';
+    is rt69915m( :a, 23 ), 'Bool()~Int()', 'WHAT method on bool and int';
+
+    sub wm($x) { return $x.WHAT }
+    sub rt69915wm( $a, $b ) { return wm($a) ~ '~' ~ wm($b) }
+    is rt69915wm( a => 42, 23 ), 'Int()~Int()', 'WHAT method on ints via func';
+    
+    sub wf($x) { return WHAT($x) }
+    sub rt69915wf( $a, $b ) { return wf($a) ~ '~' ~ wf($b) }
+    is rt69915wf( a => 42, 23 ), 'Int()~Int()', 'WHAT func on ints via func';
+}
+
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 21, 2009

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

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

From @moritz

tests now pass; closing ticket

@p6rt
Copy link
Author

p6rt commented Mar 9, 2010

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

@p6rt p6rt closed this as completed Mar 9, 2010
@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