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

cannot assign boolean evaluation to non-container #2909

Closed
p6rt opened this issue Oct 4, 2012 · 4 comments
Closed

cannot assign boolean evaluation to non-container #2909

p6rt opened this issue Oct 4, 2012 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 4, 2012

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

Searchable as RT115132$

@p6rt
Copy link
Author

p6rt commented Oct 4, 2012

From @grondilu

Hi,

My version of rakudo​:
This is perl6 version 2012.09.1-7-gfb11f13 built on parrot 4.8.0 revision RELEASE_4_8_0

I was trying to use an environment variable to assign a boolean
to a constant​:

BEGIN { %*ENV<FOO> //= "bar" }
constant FOO_IS_BAR = %*ENV<FOO> ~~ "bar" | "Bar";

I got the following error​:
===SORRY!===
Cannot assign to a non-container

shell returned 1

The error can be reproduced quicker this way (but it has less meaning)​:

constant x = "foo" ~~ /bar/;

The same line does not produce any error with niecza.

Regards

@p6rt
Copy link
Author

p6rt commented Oct 7, 2014

From @usev6

Hi,

this works now (probably for a while, already). I added a test to S04-declarations/constant.t with the following commit​: Raku/roast@6cc8c38a1c

Please note​: If you smart match agains a regex you don't get a boolean value but either a Match object or Nil​:

("foo" ~~ /foo/).WHAT.say
(Match)
("foo" ~~ /bar/).WHAT.say
Nil

As per S03 you can use "so" to force a Bool value​:

("foo" ~~ /foo/).so
True
("foo" ~~ /bar/).so
False

But that's only a minor point, the assignment to a constant works for all versions.

@p6rt
Copy link
Author

p6rt commented Oct 7, 2014

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

@p6rt p6rt closed this as completed Oct 7, 2014
@p6rt
Copy link
Author

p6rt commented Oct 7, 2014

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

@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