Skip to content

Commit

Permalink
Fix lambdas without braces as arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Oct 22, 2017
1 parent bb128e3 commit e2b6078
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/main/php/lang/ast/Parse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ private function setup() {
$signature= [[[$left->value, false, null, false, false, null]], null];
$node->value= [$signature, $this->expression(0)];
$node->arity= 'lambda';
$this->token= new Node($this->symbol(';'));
return $node;
});

Expand Down
12 changes: 12 additions & 0 deletions src/test/php/lang/ast/unittest/emit/LambdasTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ public function run() {
$this->assertEquals(2, $r(1));
}

#[@test]
public function without_braces_as_argument() {
$r= $this->run('class <T> {
private function apply($f, ... $args) { return $f(...$args); }
public function run() {
return $this->apply($a ==> $a + 1, 2);
}
}');

$this->assertEquals(3, $r);
}

#[@test]
public function without_params() {
$r= $this->run('class <T> {
Expand Down

0 comments on commit e2b6078

Please sign in to comment.