Add casting back for cast_expression. Disable cast test on Nim < 1.0.0

This commit is contained in:
Joey Yakimowich-Payne 2020-04-20 13:38:27 -06:00
commit ac646a9fea
2 changed files with 9 additions and 2 deletions

View file

@ -258,7 +258,7 @@ proc processParenthesizedExpr(exprParser: ExprParser, node: TSNode, typeofNode:
result.add(exprParser.processTSNode(node[i], typeofNode))
proc processCastExpression(exprParser: ExprParser, node: TSNode, typeofNode: var PNode): PNode =
result = nkCall.newTree(
result = nkCast.newTree(
exprParser.processTSNode(node[0], typeofNode),
exprParser.processTSNode(node[1], typeofNode)
)

View file

@ -3,11 +3,16 @@ import macros, os, sets, strutils
import nimterop/[cimport]
static:
# Skip casting on lower nim compilers because
# the VM does not support it
when (NimMajor, NimMinor, NimPatch) < (1, 0, 0):
cSkipSymbol @["CASTEXPR"]
cDebug()
const
path = currentSourcePath.parentDir() / "include" / "tast2.h"
when defined(HEADER):
cDefine("HEADER")
const
@ -118,7 +123,9 @@ assert BINEXPR == 5
assert BOOL == true
assert MATHEXPR == -99
assert ANDEXPR == 96
assert CASTEXPR == 34.chr
when (NimMajor, NimMinor, NimPatch) >= (1, 0, 0):
assert CASTEXPR == 34.chr
assert TRICKYSTR == "N\x1C\nfoo\x00\'\"\c\v\a\b\e\f\t\\\\?bar"
assert NULLCHAR == '\0'