mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-12 14:23:45 +00:00
fixes #22284 fixes #22282 ``` Error: j(uRef, proc (config: F; sources: auto) {.raises: [].} = discard ) can raise an unlisted exception: Exception ``` The problem is that `n.typ.n` contains the effectList which shouldn't appear in the parameter of a function defintion. We could not simply use `n.typ.n` as `n[paramsPos]`. The effect lists should be stripped away anyway.
25 lines
641 B
Nim
25 lines
641 B
Nim
discard """
|
|
errormsg: "j(uRef, proc (config: F; sources: auto) {.raises: [].} = discard ) can raise an unlisted exception: Exception"
|
|
"""
|
|
|
|
import std/macros
|
|
|
|
macro h(): untyped =
|
|
result = newTree(nnkStmtList)
|
|
result.add quote do:
|
|
new int
|
|
|
|
type F = object
|
|
|
|
proc j[SecondarySources](
|
|
uRef: ref SecondarySources,
|
|
u: proc (config: F, sources: ref SecondarySources)): F =
|
|
u(result, uRef)
|
|
|
|
template programMain(body: untyped) =
|
|
proc main {.raises: [].} = body # doesn't SIGSEGV without this {.raises: [].}
|
|
main()
|
|
|
|
programMain:
|
|
var uRef = h()
|
|
discard j(uRef, u = proc(config: F, sources: auto) {.raises: [].} = discard) |