#1204 Don't allow |A->| function signatures

vkuzkokov Fri 10 Sep 2010

On compiling this:

class Temp
{
  Void doSth(|Str?->| f) { }
  static Void main() { }
}

I get:

/Users/vkuzkokov/tmp/test.fan(3,24): Expected '|', not ')'

Changing signature to |Str? ->| helps. Seems like ?-> is parsed as one token. Though we can enforce using ? -> in type signatures, it would help to see something like

/Users/vkuzkokov/tmp/test.fan(3,18): Expected '|', not '?->'

brian Fri 10 Sep 2010

The signature |Str?->| isn't a legal function type. It needs to be either |Str?| or |Str?->ReturnType|. The ?-> token is handled though (Parser.fan line 2204).

vkuzkokov Fri 10 Sep 2010

So far |A->| worked exactly as |A->Void| in every context possible.

brian Fri 10 Sep 2010

Renamed from ?-> in closure signatures to Don't allow |A->| function signatures

brian Fri 10 Sep 2010

Promoted to ticket #1204 and assigned to brian

So far |A->| worked exactly as |A->Void| in every context possible.

Ok, that is a bug. The grammar is defined as:

<funcType> :=  "|" [formals] ["->" <type>] "|"

I will take a look.

brian Sun 12 Sep 2010

Ticket resolved in 1.0.55

Tightened up the parser so that function type signatures with parameters must either omit the arrow or include an explicit return type.

Login or Signup to reply.