Remove immediate pragma (#11308)
* remove immediate from tests * remove immediate from the compiler
This commit is contained in:
parent
eb471acffb
commit
5b27b263fd
22 changed files with 53 additions and 116 deletions
|
|
@ -6,7 +6,6 @@ foo55
|
|||
foo8.0
|
||||
fooaha
|
||||
bar7
|
||||
immediate
|
||||
10
|
||||
4true
|
||||
132
|
||||
|
|
@ -123,21 +122,6 @@ block pattern_with_converter:
|
|||
|
||||
|
||||
|
||||
block prefer_immediate:
|
||||
# Test that immediate templates are preferred over non-immediate templates
|
||||
|
||||
template foo(a, b: untyped) = echo "foo expr"
|
||||
template foo(a, b: int) = echo "foo int"
|
||||
template foo(a, b: float) = echo "foo float"
|
||||
template foo(a, b: string) = echo "foo string"
|
||||
template foo(a, b: untyped) {.immediate.} = echo "immediate"
|
||||
template foo(a, b: bool) = echo "foo bool"
|
||||
template foo(a, b: char) = echo "foo char"
|
||||
|
||||
foo(undeclaredIdentifier, undeclaredIdentifier2)
|
||||
|
||||
|
||||
|
||||
|
||||
block procparshadow:
|
||||
template something(name: untyped) =
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ discard """
|
|||
file: "ttempl2.nim"
|
||||
line: 18
|
||||
"""
|
||||
template declareInScope(x: untyped, t: typeDesc): untyped {.immediate.} =
|
||||
template declareInScope(x: untyped, t: typeDesc): untyped =
|
||||
var x: t
|
||||
|
||||
template declareInNewScope(x: untyped, t: typeDesc): untyped {.immediate.} =
|
||||
template declareInNewScope(x: untyped, t: typeDesc): untyped =
|
||||
# open a new scope:
|
||||
block:
|
||||
var x: t
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ var `hu "XYZ"` = "yay"
|
|||
|
||||
echo prefix(XYZ)
|
||||
|
||||
template typedef(name: untyped, typ: typeDesc) {.immediate, dirty.} =
|
||||
template typedef(name: untyped, typ: typeDesc) {.dirty.} =
|
||||
type
|
||||
`T name`* = typ
|
||||
`P name`* = ref `T name`
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ discard """
|
|||
type Foo* {.pure, final.} = object
|
||||
elt: float
|
||||
|
||||
template defineOpAssign(T, op: untyped) {.immediate.} =
|
||||
proc op*(v: var T, w: T) {.inline.} =
|
||||
template defineOpAssign(T, op: untyped) =
|
||||
proc `op`*(v: var T, w: T) {.inline.} =
|
||||
for i in 0..1:
|
||||
op(v.elt, w.elt)
|
||||
`op`(v.elt, w.elt)
|
||||
|
||||
const ATTEMPT = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -18,14 +18,19 @@ test "previous definitions can be further overloaded or hidden in local scopes":
|
|||
check t("test") == "string"
|
||||
|
||||
test "templates can be redefined multiple times":
|
||||
template customAssert(cond: bool, msg: string): typed {.immediate, dirty.} =
|
||||
template customAssert(cond: bool, msg: string): typed {.dirty.} =
|
||||
if not cond: fail(msg)
|
||||
|
||||
template assertion_failed(body: typed) {.immediate, dirty.} =
|
||||
template fail(msg: string): typed = body
|
||||
template assertionFailed(body: untyped) {.dirty.} =
|
||||
template fail(msg: string): typed =
|
||||
body
|
||||
|
||||
assertionFailed:
|
||||
check(msg == "first fail path")
|
||||
|
||||
assertion_failed: check msg == "first fail path"
|
||||
customAssert false, "first fail path"
|
||||
|
||||
assertion_failed: check msg == "second fail path"
|
||||
assertionFailed:
|
||||
check(msg == "second fail path")
|
||||
|
||||
customAssert false, "second fail path"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue