develooper Front page | perl.perl6.compiler | Postings from March 2018

[perl #131508] [BUG] `state` with % is Sethash in whenever blockends up with a type object on second iteration

Thread Previous
From:
Zoffix Znet via RT
Date:
March 7, 2018 01:26
Subject:
[perl #131508] [BUG] `state` with % is Sethash in whenever blockends up with a type object on second iteration
Message ID:
rt-4.0.24-24709-1520385984-54.131508-15-0@perl.org
On Sun, 04 Jun 2017 07:12:25 -0700, cpan@zoffix.com wrote:
> %goods here works as expected:
> 
> <Zoffix__> m: my %goods is SetHash; react whenever Supply.interval(.3)
> { $++ > 3 and done; dd %goods; %goods<foo>++; }
> <camelia> rakudo-moar 3755c0: OUTPUT:
> «SetHash.new()␤SetHash.new("foo")␤SetHash.new("foo")␤SetHash.new("foo")␤»
> 
> On second iteration ends up being a type object:
> 
> <Zoffix__> m: react whenever Supply.interval(.3) { state %goods is
> SetHash; $++ > 3 and done; dd %goods; %goods<foo>++; }
> <camelia> rakudo-moar 3755c0: OUTPUT: «SetHash.new()␤SetHash␤Tried to
> get the result of a broken Promise␤  in block <unit> at <tmp> line
> 1␤␤Original exception:␤    Cannot modify an immutable SetHash
> ((SetHash))␤      in block  at <tmp> line 1␤␤»

Another case:

```
<Zoffix_> m: <a b c>.grep: { (state %code-files is SetHash = <foo bar>); LEAVE dd %code-files; }
<camelia> rakudo-moar dd2c90192: OUTPUT: «SetHash.new("foo","bar")␤SetHash␤SetHash␤»
```

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About