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

Defining several constants with parentheses doesn't work in Rakudo #1359

Closed
p6rt opened this issue Oct 13, 2009 · 7 comments
Closed

Defining several constants with parentheses doesn't work in Rakudo #1359

p6rt opened this issue Oct 13, 2009 · 7 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 13, 2009

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

Searchable as RT69740$

@p6rt
Copy link
Author

p6rt commented Oct 13, 2009

From @masak

<moritz_> perl6​: constant ($a, $b) = 1, 2; say "$a $b"
<p6eval> rakudo d749d9​: OUTPUT«No applicable methods. [...]
[...]
<moritz_> ouch, that looks like a rakudobug
<moritz_> rakudo​: constant $a = 3; say $a
<p6eval> rakudo d749d9​: OUTPUT«3␤»
<shinobi-cl> i was trying to define many constants in a compact way
<moritz_> masak​: care to submit? :-)
* masak cares to submit
<moritz_> std​: constant ($a, $b) = 1, 2; say "$a $b"
<p6eval> std 28773​: OUTPUT«ok 00​:02 115m␤»

@p6rt
Copy link
Author

p6rt commented Oct 13, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-declarations/constant.t

commit bb301917e805250f795bccf238ad292f33376700
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Oct 13 12​:20​:46 2009 +0000

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

Inline Patch
diff --git a/t/spec/S04-declarations/constant.t b/t/spec/S04-declarations/constant.t
index fade05c..b207465 100644
--- a/t/spec/S04-declarations/constant.t
+++ b/t/spec/S04-declarations/constant.t
@@ -2,30 +2,37 @@ use v6;
 
 use Test;
 
-plan 33;
+plan *;
 
 # L<S04/The Relationship of Blocks and Declarations/"The new constant declarator">
 
 # Following tests test whether the declaration succeeded.
 #?pugs todo 'feature'
 {
-    my $ok;
-
     constant foo = 42;
-    $ok = foo == 42;
 
-    ok $ok, "declaring a sigilless constant using 'constant' works";
+    ok foo == 42, "declaring a sigilless constant using 'constant' works";
+    dies_ok { foo = 3 }, "can't reasign to a sigil-less constant";
 }
 
 {
     my $ok;
 
     constant $bar = 42;
-    $ok = $bar == 42;
+    ok $bar == 42, "declaring a constant with a sigil using 'constant' works";
+    dies_ok { $bar = 2 }, "Can't reasign to a sigiled constant";
+}
 
-    ok $ok, "declaring a constant with a sigil using 'constant' works";
+#?rakudo skip 'RT 69740'
+{
+    constant ($a, $b) = (3, 4);
+    is $a, 3, 'multiple constant in one declaration(1)';
+    is $b, 4, 'multiple constant in one declaration(2)';
+    dies_ok { $a = 4 }, 'and they are really constant (1)';
+    dies_ok { $b = 4 }, 'and they are really constant (2)';
 }
 
+
 {
     {
         constant foo2 = 42;
@@ -239,4 +246,6 @@ plan 33;
              'assign constant its own value from expression';
 }
 
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 13, 2009

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

@p6rt
Copy link
Author

p6rt commented Aug 2, 2010

From @bbkr

[12​:23] <bbkr> std​: constant ($a, $b) = 1,2;
[12​:23] <p6eval> std 31886​:
OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Malformed constant at
/tmp/xCgHKZ1I4w line 1​:␤------> �[32mconstant �[33m⏏�[31m($a, $b) =
1,2;�[0m␤ expecting any of​:␤ trait␤ type_declarator␤Parse
failed␤FAILED 00​:01 113m␤»
[12​:23] <-- gbacon has left this server (Ping timeout​: 265 seconds).
[12​:24] --> wamba has joined this channel (~wamba@​193-194.moravanet.cz).
[12​:24] <bbkr> that constant definition has changed since
http://rt.perl.org/rt3/Ticket/Display.html?id=69740 , is there any new
syntax now for compact constant declaration?
[12​:24] <moritz_> constant a = 3;
[12​:25] <moritz_> my constant $x = 5;
[12​:25] <moritz_> iirc
[12​:25] <moritz_> std​: constant a = 5; a
[12​:25] <p6eval> std 31886​: OUTPUT«ok 00​:01 116m␤»
[12​:25] <moritz_> std​: my constant $x = 5; $x
[12​:25] <p6eval> std 31886​: OUTPUT«ok 00​:01 117m␤»
[12​:26] <bbkr> moritz_​: ticket refers to declaring multiple constants in
one line. which was valid then, but it is not now.
[12​:26] --> barika has joined this channel (~tbalazs@​cg.iit.bme.hu).
[12​:26] <moritz_> std​: my contant ($x, $y) = (1, 2); say $x
[12​:26] <p6eval> std 31886​:
OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Malformed my at /tmp/hcnyL11DxB
line 1​:␤------> �[32mmy �[33m⏏�[31mcontant ($x, $y) = (1, 2); say
$x�[0m␤ expecting any of​:␤ scoped declarator␤ typename␤Parse
failed␤FAILED 00​:01 114m␤»
[12​:26] <moritz_> std​: my constant ($x, $y) = (1, 2); say $x
[12​:26] <p6eval> std 31886​:
OUTPUT«�[31m===�[0mSORRY!�[31m===�[0m␤Malformed constant at
/tmp/6XjhLVJODB line 1​:␤------> �[32mmy constant �[33m⏏�[31m($x, $y) =
(1, 2); say $x�[0m␤ expecting any of​:␤ trait␤ type_declarator␤Parse
failed␤FAILED 00​:01 114m␤»
[12​:27] <bbkr> so what status should ticket have? rejected, because STD
has changed?
[12​:27] <moritz_> yes
[12​:27] <moritz_> bbkr​: and please make sure the tests are gone
[12​:27] <bbkr> moritz_​: thanks. i'll also remove fudged test
[12​:27] <bbkr> reading my mind ;)

taking ticket...

@p6rt
Copy link
Author

p6rt commented Aug 2, 2010

From @bbkr

there was already test for constant list assignment forbidden in
t/spec/S04-declarations/constant.t

unfudged it.

@p6rt
Copy link
Author

p6rt commented Aug 2, 2010

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

@p6rt p6rt closed this as completed Aug 2, 2010
@p6rt
Copy link
Author

p6rt commented Aug 2, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S04-declarations/constant.t

commit 0b93fd8ad7b19c5ca28b5456306327e4be20fb31
Author​: bbkr <bbkr@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Mon Aug 2 11​:24​:01 2010 +0000

  [t/spec] tests for RT #​69740 Defining several constants with parentheses
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31888 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S04-declarations/constant.t b/t/spec/S04-declarations/constant.t
index 9b2b871..412ae35 100644
--- a/t/spec/S04-declarations/constant.t
+++ b/t/spec/S04-declarations/constant.t
@@ -23,7 +23,7 @@ plan *;
     dies_ok { $bar = 2 }, "Can't reassign to a sigiled constant";
 }
 
-#?rakudo skip 'RT 69740'
+# RT #69740
 {
     eval_dies_ok 'constant ($a, $b) = (3, 4)', 'constant no longer takes list';
 }

@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