snow-deprecated icon indicating copy to clipboard operation
snow-deprecated copied to clipboard

`return it` in block doesn't work

Open Mikoangelo opened this issue 16 years ago • 4 comments
trafficstars

When creating a Function returning the magic variable it, nil is returned:

a: [n] { n }
b: { it }
c: [n] { return n }
d: { return it }

puts("a: " + a(60)) //→ a: 60
puts("b: " + b(60)) //→ b: 60
puts("c: " + c(60)) //→ c: 60
puts("d: " + d(60)) //→ d: 

Interestingly, this works in interactive Snow:

{ return it }(60) //→ 60

Mikoangelo avatar Jun 22 '09 22:06 Mikoangelo

This is probably related to #26; I will look into it.

Also, please provide revision and architecture. :)

simonask avatar Jun 23 '09 06:06 simonask

The reason this works in Interactive Snow

{ return it }(60)   //=> 60

is an error in the parser.

This would give the same result:

{ return 78 }(60)  // => 60

simonask avatar Jun 23 '09 06:06 simonask

Hahaha, that's pretty messed up.

Sorry about the lack of info. Architecture is x86_64, revision is current HEAD, 3489b36551e3f426ac7e0885fd8d9eb19a4dca35.

Mikoangelo avatar Jun 23 '09 11:06 Mikoangelo

Made a separate ticket about the parser issue - see #29.

ghost avatar Jun 23 '09 15:06 ghost