mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 01:14:41 +00:00
* Breaking parser changes, implement https://github.com/nim-lang/RFCs/issues/442 Types are separated from expressions and better reflected in the grammar. * add test * more accurate grammar * fix keyword typedescs * accept expressions in proc argument lists * CI "fixes" * fixes * allow full ref expressions again, adapt old tests * cleanup, fix some tests * improve grammar, try and revert semtypes change * restrict sigil binding to identOrLiteral * fix, should have caught this immediately * add changelog entry, fix double not nil bug * correct grammar * change section * fix * real fix hopefully * fix test * support LL(1) for tuples * make grammar.txt too
43 lines
1.2 KiB
Nim
43 lines
1.2 KiB
Nim
discard """
|
|
cmd: "nim check --hint:Conf:off --hint:XDeclaredButNotUsed:off $file"
|
|
nimout: '''
|
|
teffects1.nim(17, 28) template/generic instantiation from here
|
|
'''
|
|
"""
|
|
{.push warningAsError[Effect]: on.}
|
|
type
|
|
TObj {.pure, inheritable.} = object
|
|
TObjB = object of TObj
|
|
a, b, c: string
|
|
|
|
IO2Error = ref object of IOError
|
|
|
|
proc forw: int {. .}
|
|
|
|
proc lier(): int {.raises: [IO2Error].} = #[tt.Hint
|
|
^ 'lier' cannot raise 'IO2Error' [XCannotRaiseY] ]#
|
|
writeLine stdout, "arg" #[tt.Error
|
|
^ writeLine stdout, ["arg"] can raise an unlisted exception: ref IOError ]#
|
|
|
|
proc forw: int =
|
|
raise newException(IOError, "arg")
|
|
|
|
{.push raises: [Defect].}
|
|
|
|
type
|
|
MyProcType* = proc(x: int): string #{.raises: [ValueError, Defect].}
|
|
|
|
proc foo(x: int): string {.nimcall, raises: [ValueError].} =
|
|
if x > 9:
|
|
raise newException(ValueError, "Use single digit")
|
|
$x
|
|
|
|
var p: MyProcType = foo #[tt.Error
|
|
^
|
|
type mismatch: got <proc (x: int): string{.nimcall, noSideEffect, gcsafe.}> but expected 'MyProcType = proc (x: int): string{.closure.}'
|
|
Calling convention mismatch: got '{.nimcall.}', but expected '{.closure.}'.
|
|
.raise effects differ
|
|
]#
|
|
{.pop.}
|
|
{.pop.}
|