deprecate do: meaning do (): + misc cleanup (#20927)

* test disable do: block lambda lifting

* fix last test [skip ci]

* deprecate `do:` meaning `do ():` + misc cleanup

closes https://github.com/nim-lang/RFCs/issues/486

* oops

* fix

* no idea what could be causing nimsuggest failure other than this

* ensure ci works
This commit is contained in:
metagn 2022-12-06 11:44:26 +03:00 • committed by GitHub
commit 6d8cf25bd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 42 additions and 65 deletions

View file

@ -239,19 +239,19 @@ block doNotation:
b.onClick do (e: Event):
echo "click at ", e.x, ",", e.y
b.onFocusLost:
b.onFocusLost do ():
echo "lost focus 1"
b.onFocusLost do:
b.onFocusLost do ():
echo "lost focus 2"
b.onUserEvent("UserEvent 1") do:
b.onUserEvent("UserEvent 1") do ():
discard
b.onUserEvent "UserEvent 2":
onUserEvent(b, "UserEvent 2") do ():
discard
b.onUserEvent("UserEvent 3"):
b.onUserEvent("UserEvent 3") do ():
discard
b.onUserEvent("UserEvent 4", () => echo "event 4")

View file

@ -71,12 +71,12 @@ block tissue7104:
proc sp(cb: proc())=
cb()
sp:
sp do ():
var i = 0
echo "ok ", i
sp():
sp do ():
inc i
echo "ok ", i
sp do:
sp do ():
inc i
echo "ok ", i

View file

@ -0,0 +1,9 @@
discard """
action: compile
"""
proc foo(x: proc()) = x()
foo: echo "a" #[tt.Warning
^ statement list expression assumed to be anonymous proc; this is deprecated, use `do (): ...` or `proc () = ...` instead [StmtListLambda]]#
foo do: echo "b" #[tt.Warning
^ statement list expression assumed to be anonymous proc; this is deprecated, use `do (): ...` or `proc () = ...` instead [StmtListLambda]]#

View file

@ -217,7 +217,7 @@ block:
on("click") do (e: Event):
console.log e
jslib.on("reloaded") do:
jslib.on("reloaded") do ():
console.log jsarguments[0]
# this test case is different from the above, because

View file

@ -321,7 +321,7 @@ block:
on("click") do (e: Event):
console.log e
jslib.on("reloaded") do:
jslib.on("reloaded") do ():
console.log jsarguments[0]
# this test case is different from the above, because

View file

@ -67,7 +67,7 @@ proc main2() =
proc foo() =
subscriber.consume()
emitter.on_event() do:
emitter.on_event() do ():
subscriber.consume()
# this works

View file

@ -1,4 +1,4 @@
{.push warningAsError[TemplateRedefinition]: on.}
{.push warningAsError[ImplicitTemplateRedefinition]: on.}
doAssert not (compiles do:
template foo(): int = 1