Remove support for named procs with sugar.=> (#17220)
* Add docs & tests for named procs with sugar.=> * Remove support for named procs in sugar.=> * Resolve conflict * Fix test
This commit is contained in:
parent
8f1fa3e5b0
commit
2e8325a19c
3 changed files with 5 additions and 18 deletions
|
|
@ -194,6 +194,9 @@ provided by the operating system.
|
||||||
- `system.addEscapedChar` now renders `\r` as `\r` instead of `\c`, to be compatible
|
- `system.addEscapedChar` now renders `\r` as `\r` instead of `\c`, to be compatible
|
||||||
with most other languages.
|
with most other languages.
|
||||||
|
|
||||||
|
- Removed support for named procs in `sugar.=>`
|
||||||
|
|
||||||
|
|
||||||
## Language changes
|
## Language changes
|
||||||
|
|
||||||
- `nimscript` now handles `except Exception as e`.
|
- `nimscript` now handles `except Exception as e`.
|
||||||
|
|
|
||||||
|
|
@ -87,16 +87,6 @@ macro `=>`*(p, b: untyped): untyped =
|
||||||
|
|
||||||
checkPragma(p, pragma) # check again after -> transform
|
checkPragma(p, pragma) # check again after -> transform
|
||||||
|
|
||||||
since (1, 3):
|
|
||||||
if p.kind in {nnkCall, nnkObjConstr}:
|
|
||||||
# foo(x, y) => x + y
|
|
||||||
kind = nnkProcDef
|
|
||||||
name = p[0]
|
|
||||||
let newP = newNimNode(nnkPar)
|
|
||||||
for i in 1..<p.len:
|
|
||||||
newP.add(p[i])
|
|
||||||
p = newP
|
|
||||||
|
|
||||||
case p.kind
|
case p.kind
|
||||||
of nnkPar, nnkTupleConstr:
|
of nnkPar, nnkTupleConstr:
|
||||||
var untypedBeforeColon = 0
|
var untypedBeforeColon = 0
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ calling mystuff
|
||||||
yes
|
yes
|
||||||
calling mystuff
|
calling mystuff
|
||||||
yes
|
yes
|
||||||
calling sugarWithPragma
|
|
||||||
sugarWithPragma called
|
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -40,7 +38,7 @@ proc pass2(f: (int, int) -> int): (int) -> int =
|
||||||
|
|
||||||
doAssert pass2((x, y) => x + y)(4) == 6
|
doAssert pass2((x, y) => x + y)(4) == 6
|
||||||
|
|
||||||
fun(x, y: int) {.noSideEffect.} => x + y
|
const fun = (x, y: int) {.noSideEffect.} => x + y
|
||||||
|
|
||||||
doAssert typeof(fun) is (proc (x, y: int): int {.nimcall.})
|
doAssert typeof(fun) is (proc (x, y: int): int {.nimcall.})
|
||||||
doAssert fun(3, 4) == 7
|
doAssert fun(3, 4) == 7
|
||||||
|
|
@ -70,9 +68,7 @@ m:
|
||||||
proc mystuff() =
|
proc mystuff() =
|
||||||
echo "yes"
|
echo "yes"
|
||||||
|
|
||||||
sugarWithPragma() {.m.} => echo "sugarWithPragma called"
|
const typedParamAndPragma = (x, y: int) -> int => x + y
|
||||||
|
|
||||||
typedParamAndPragma(x, y: int) {.used.} -> int => x + y
|
|
||||||
doAssert typedParamAndPragma(1, 2) == 3
|
doAssert typedParamAndPragma(1, 2) == 3
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
@ -82,5 +78,3 @@ type
|
||||||
var myBot = Bot()
|
var myBot = Bot()
|
||||||
myBot.call = () {.noSideEffect.} => "I'm a bot."
|
myBot.call = () {.noSideEffect.} => "I'm a bot."
|
||||||
doAssert myBot.call() == "I'm a bot."
|
doAssert myBot.call() == "I'm a bot."
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue