Skip Menu |
Report information
Id: 124979
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: davidnmfarrell [at] gmail.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Sun, 3 Dec 2017 13:45:55 +0800
To: perl6-bugs-followup [...] perl.org
Subject: [perl #124979]
From: 陈梓立 <wander4096 [...] gmail.com>
Download (untitled) / with headers
text/plain 629b
This is not limited in operator overloading

```
my $a;
$a := { $^a + $^b }
# ok
```

```
my &a;
&a := { $^a + $^b }
Cannot use bind operator with this left-hand side
```

```
my &a := { $^a + $^b }
say a(1, 2)
# 3
```

```
my &infix:<plus> := { $^a + $^b };

say 1 plus 2 plus 3

# 6
```


Note that it is all well if use `=` instead of `:=`

```
{
  my &infix:<plus>;
  BEGIN {
    &infix:<plus> = { $^a + $^b };
  }

  is 3 plus 5, 8, 'overloading an operator using "my &infix:<...>" worked';
}
ok 1 - overloading an operator using "my &infix:<...>" worked
```

This test is moved to S06-operator-overloading/infix.t, BTW


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org