Remove immediate pragma (#11308)

* remove immediate from tests
* remove immediate from the compiler
This commit is contained in:
Arne Döring 2019-05-29 22:21:51 +02:00 • committed by Andreas Rumpf
commit 5b27b263fd
22 changed files with 53 additions and 116 deletions

View file

@ -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) =

View file

@ -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

View file

@ -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`

View file

@ -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

View file

@ -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"