Code Review: arity


tfpt review “/shelveset:arity;REDMOND\tomat”
Comment :
Fixes bugs in block parameters:

  1. Anonymous unsplat parameters were not handled correctly (the
    parser ignored them):
    def y
    a = [1,2,3,4,5]
    yield a,[6]

y { |(x,y,),| p x,y }
2) Arity wasn’t calculated correctly. Arity depends upon AST
structure that is not preserved in runtime. Therefore we need to
calculate block arity at compile time and save it to BlockDispatcher.
Some peculiar cases:{|(a,b,c,)|}.arity.should == -4{|(
)|}.arity.should == -1{}.arity.should == -1{||}.arity.should == 0{x,}.arity.should == 1{(x,)}.arity.should == 1



Looks good. One minor formatting problem: Some of the changed parts of
parser.y are now using tab characters instead of spaces.

In the BlockSignatureAttributes enumeration (in BlockDispatcher.cs),
there’s a comment that “bits 31…3 store arity”. Are you numbering bits
from 1? I’m used to numbering them from zero :).