Files
Nim/tests/pragmas/tpush.nim
ringabout d20b4d5168 fixes #23019; Regression from 2.0 to devel with raise an unlisted exc… (#23034)
…eption: Exception

fixes #23019

I suppose `implicitPragmas` is called somewhere which converts
`otherPragmas`.
2023-12-05 21:04:41 +01:00

102 lines
1.5 KiB
Nim

discard """
targets: "c js"
"""
# test the new pragmas
{.push warnings: off, hints: off.}
proc noWarning() =
var
x: int
echo(x)
{.pop.}
proc WarnMe() =
var
x: int
echo(x)
# bug #11852
proc foo(x: string, y: int, res: int) =
{.push checks: off}
var a: ptr char = unsafeAddr(x[y])
{.pop.}
if x.len > y:
doAssert ord(a[]) == 51
else:
doAssert x.len + 48 == res
foo("", 0, 48)
foo("abc", 40, 51)
# bug #22362
{.push staticBoundChecks: on.}
proc main(): void =
{.pop.}
discard
{.push staticBoundChecks: on.}
main()
proc timnFoo[T](obj: T) {.noSideEffect.} = discard # BUG
{.push exportc.}
proc foo1() =
var s1 = "bar"
timnFoo(s1)
var s2 = @[1]
timnFoo(s2)
{.pop.}
block: # bug #22913
block:
type r = object
template std[T](x: T) =
let ttt {.used.} = x
result = $ttt
proc bar[T](x: T): string =
std(x)
{.push exportc: "$1".}
proc foo(): r =
let s = bar(123)
{.pop.}
discard foo()
block:
type r = object
{.push exportc: "$1".}
proc foo2(): r =
let s = $result
{.pop.}
discard foo2()
block: # bug #23019
proc f(x: bool)
proc a(x: int) =
if false: f(true)
proc f(x: bool) =
if false: a(0)
proc k(r: int|int) {.inline.} = # seems to require being generic and inline
if false: a(0)
# {.push tags: [].}
{.push raises: [].}
{.push warning[ObservableStores]:off.} # can be any warning, off or on
let w = 0
k(w)
{.pop.}
{.pop.}