parent
433ce7bea2
commit
aeb6ec27de
5 changed files with 41 additions and 8 deletions
|
|
@ -36,6 +36,9 @@
|
||||||
|
|
||||||
- Compile time checks for integer and float conversions are now stricter. For example, `const x = uint32(-1)` now gives a compile time error instead of being equivalent to `const x = 0xFFFFFFFF'u32`.
|
- Compile time checks for integer and float conversions are now stricter. For example, `const x = uint32(-1)` now gives a compile time error instead of being equivalent to `const x = 0xFFFFFFFF'u32`.
|
||||||
|
|
||||||
|
- A bug allowed ``macro foo(): int = 123`` to compile even though a
|
||||||
|
macros has to return a ``NimNode``. This has been fixed.
|
||||||
|
|
||||||
#### Breaking changes in the standard library
|
#### Breaking changes in the standard library
|
||||||
|
|
||||||
- `osproc.execProcess` now also takes a `workingDir` parameter.
|
- `osproc.execProcess` now also takes a `workingDir` parameter.
|
||||||
|
|
|
||||||
|
|
@ -1550,7 +1550,15 @@ proc activate(c: PContext, n: PNode) =
|
||||||
|
|
||||||
proc maybeAddResult(c: PContext, s: PSym, n: PNode) =
|
proc maybeAddResult(c: PContext, s: PSym, n: PNode) =
|
||||||
if s.typ.sons[0] != nil and not isInlineIterator(s):
|
if s.typ.sons[0] != nil and not isInlineIterator(s):
|
||||||
addResult(c, s.typ.sons[0], n.info, s.kind)
|
let resultType =
|
||||||
|
if s.kind == skMacro:
|
||||||
|
if s.typ.sons[0].kind == tyTypeDesc:
|
||||||
|
s.typ.sons[0]
|
||||||
|
else:
|
||||||
|
sysTypeFromName(c.graph, n.info, "NimNode")
|
||||||
|
else:
|
||||||
|
s.typ.sons[0]
|
||||||
|
addResult(c, resultType, n.info, s.kind)
|
||||||
addResultNode(c, n)
|
addResultNode(c, n)
|
||||||
|
|
||||||
proc canonType(c: PContext, t: PType): PType =
|
proc canonType(c: PContext, t: PType): PType =
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
nimout: '''
|
nimout: '''
|
||||||
instantiation 1 with None and None
|
instantiation 1 with typeDesc[int] and typeDesc[float]
|
||||||
instantiation 2 with None and None
|
instantiation 2 with typeDesc[float] and typeDesc[string]
|
||||||
instantiation 3 with None and None
|
instantiation 3 with typeDesc[string] and typeDesc[string]
|
||||||
counter: 3
|
counter: 3
|
||||||
'''
|
'''
|
||||||
output: "int\nfloat\nint\nstring"
|
output: "int\nfloat\nint\nstring"
|
||||||
|
|
@ -14,7 +14,7 @@ var counter {.compileTime.} = 0
|
||||||
|
|
||||||
macro makeBar(A, B: typedesc): typedesc =
|
macro makeBar(A, B: typedesc): typedesc =
|
||||||
inc counter
|
inc counter
|
||||||
echo "instantiation ", counter, " with ", A.name, " and ", B.name
|
echo "instantiation ", counter, " with ", A.getTypeInst.repr, " and ", B.getTypeInst.repr
|
||||||
result = A
|
result = A
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
discard """
|
discard """
|
||||||
output: "Got: 'nnkCall' hi"
|
output: '''Got: 'nnkCall' hi
|
||||||
|
{a}
|
||||||
|
{b}
|
||||||
|
{a, b}'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import
|
import
|
||||||
|
|
@ -27,3 +30,22 @@ var str: string
|
||||||
outterMacro(str):
|
outterMacro(str):
|
||||||
"hellow"
|
"hellow"
|
||||||
echo str
|
echo str
|
||||||
|
|
||||||
|
type E = enum a b
|
||||||
|
macro enumerators1(): set[E] = newLit({a})
|
||||||
|
|
||||||
|
macro enumerators2(): set[E] =
|
||||||
|
return newLit({b})
|
||||||
|
|
||||||
|
macro enumerators3(): set[E] =
|
||||||
|
result = newLit({E.low .. E.high})
|
||||||
|
|
||||||
|
var myEnums: set[E]
|
||||||
|
|
||||||
|
|
||||||
|
myEnums = enumerators1()
|
||||||
|
echo myEnums
|
||||||
|
myEnums = enumerators2()
|
||||||
|
echo myEnums
|
||||||
|
myEnums = enumerators3()
|
||||||
|
echo myEnums
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ block tgenericparams:
|
||||||
let expr0 = "proc foo[T, N: static[int]]()"
|
let expr0 = "proc foo[T, N: static[int]]()"
|
||||||
let expr1 = "proc foo[T; N: static[int]]()"
|
let expr1 = "proc foo[T; N: static[int]]()"
|
||||||
|
|
||||||
$toStrLit(parseExpr(expr0)) & "\n" & $toStrLit(parseExpr(expr1))
|
newLit($toStrLit(parseExpr(expr0)) & "\n" & $toStrLit(parseExpr(expr1)))
|
||||||
|
|
||||||
echo test()
|
echo test()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue