1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 fun foo
(any
: Object) do end
22 fun bar
(any
: Object) do end
26 var b
= fun do print
1 end
27 #alt1# var b2 = fun do print 1 # mandatory end
28 var b3
= (fun do print
1 end)
29 #alt2# var b3 = (fun do print 1) # still mandatory end
36 var d
= fun(a
: A
) do print
1 end
37 var d2
= fun(a
) do print
1 end # might be a sematic error but is legal syntax
39 var e
= fun: A
do return new A
end
41 var f
= fun(a
: A
, b
: B
...): C
do return a
.foo
(b
) end
43 var g
= [fun: Int do return 1 end, fun: Int do return 2 end]
45 bar
(fun do print
1 end)
46 bar
fun do print
1 end
55 (fun do print
1 end).bar
56 fun do print
1 end.bar
# this is unexpectedly legal
64 fun do fun do end.foo
fun do end end.bar
# hmmm