mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-24 00:05:25 +00:00
Fixes #7845 (Cannot raise generic exception)
(cherry picked from commit 541c2a3fec)
This commit is contained in:
@@ -4,6 +4,8 @@ discard """
|
||||
type
|
||||
ESomething = object of Exception
|
||||
ESomeOtherErr = object of Exception
|
||||
ESomethingGen[T] = object of Exception
|
||||
ESomethingGenRef[T] = ref object of Exception
|
||||
|
||||
proc genErrors(s: string) =
|
||||
if s == "error!":
|
||||
@@ -27,4 +29,17 @@ proc blah(): int =
|
||||
|
||||
echo blah()
|
||||
|
||||
# Issue #7845, raise generic exception
|
||||
var x: ref ESomethingGen[int]
|
||||
new(x)
|
||||
try:
|
||||
raise x
|
||||
except ESomethingGen[int] as e:
|
||||
discard
|
||||
|
||||
try:
|
||||
raise new(ESomethingGenRef[int])
|
||||
except ESomethingGenRef[int] as e:
|
||||
discard
|
||||
except:
|
||||
discard
|
||||
|
||||
Reference in New Issue
Block a user