mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 14:00:35 +00:00
making tests green again
This commit is contained in:
@@ -918,7 +918,7 @@ proc semAsgn(c: PContext, n: PNode): PNode =
|
||||
let nOrig = n.copyTree
|
||||
a = builtinFieldAccess(c, a, {efLValue})
|
||||
if a == nil:
|
||||
return propertyWriteAccess(c, n, nOrig, a)
|
||||
return propertyWriteAccess(c, n, nOrig, n[0])
|
||||
of nkBracketExpr:
|
||||
# a[i] = x
|
||||
# --> `[]=`(a, i, x)
|
||||
@@ -1028,7 +1028,7 @@ proc semExpandToAst(c: PContext, n: PNode, magicSym: PSym,
|
||||
|
||||
# Preserve the magic symbol in order to be handled in evals.nim
|
||||
n.sons[0] = newSymNode(magicSym, n.info)
|
||||
n.typ = expandedSym.getReturnType
|
||||
n.typ = getSysSym("PNimrodNode").typ # expandedSym.getReturnType
|
||||
result = n
|
||||
else:
|
||||
result = semDirectOp(c, n, flags)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
# Hello world program
|
||||
|
||||
echo "Hello World!"
|
||||
echo "Hello World"
|
||||
|
||||
@@ -194,15 +194,15 @@ proc lineinfo*(n: PNimrodNode): string {.magic: "NLineInfo".}
|
||||
## returns the position the node appears in the original source file
|
||||
## in the form filename(line, col)
|
||||
|
||||
proc parseExpr*(s: string): expr {.magic: "ParseExprToAst".}
|
||||
proc parseExpr*(s: string): PNimrodNode {.magic: "ParseExprToAst".}
|
||||
## Compiles the passed string to its AST representation.
|
||||
## Expects a single expression.
|
||||
|
||||
proc parseStmt*(s: string): stmt {.magic: "ParseStmtToAst".}
|
||||
proc parseStmt*(s: string): PNimrodNode {.magic: "ParseStmtToAst".}
|
||||
## Compiles the passed string to its AST representation.
|
||||
## Expects one or more statements.
|
||||
|
||||
proc getAst*(macroOrTemplate: expr): expr {.magic: "ExpandToAst".}
|
||||
proc getAst*(macroOrTemplate: expr): PNimrodNode {.magic: "ExpandToAst".}
|
||||
## Obtains the AST nodes returned from a macro or template invocation.
|
||||
## Example:
|
||||
##
|
||||
|
||||
@@ -94,7 +94,7 @@ template fail* =
|
||||
|
||||
macro check*(conditions: stmt): stmt =
|
||||
proc standardRewrite(e: PNimrodNode): PNimrodNode =
|
||||
template rewrite(Exp, lineInfoLit: expr, expLit: string): PNimrodNode =
|
||||
template rewrite(Exp, lineInfoLit: expr, expLit: string): stmt =
|
||||
if not Exp:
|
||||
checkpoint(lineInfoLit & ": Check failed: " & expLit)
|
||||
fail()
|
||||
@@ -107,7 +107,7 @@ macro check*(conditions: stmt): stmt =
|
||||
of nnkInfix:
|
||||
proc rewriteBinaryOp(op: PNimrodNode): PNimrodNode =
|
||||
template rewrite(op, left, right, lineInfoLit: expr, opLit,
|
||||
leftLit, rightLit: string, printLhs, printRhs: bool): PNimrodNode =
|
||||
leftLit, rightLit: string, printLhs, printRhs: bool): stmt =
|
||||
block:
|
||||
var
|
||||
lhs = left
|
||||
|
||||
@@ -87,7 +87,7 @@ const
|
||||
IDLE_EVENTS* = 1 shl 5 # WAS 0x10 ???? *
|
||||
ALL_EVENTS* = not DONT_WAIT
|
||||
VOLATILE* = 1
|
||||
STATIC* = 0
|
||||
TCL_STATIC* = 0
|
||||
DYNAMIC* = 3 # Channel
|
||||
TCL_STDIN* = 1 shl 1
|
||||
TCL_STDOUT* = 1 shl 2
|
||||
|
||||
@@ -6,7 +6,7 @@ template plus(a, b: expr): expr =
|
||||
a + b
|
||||
|
||||
macro call(e: expr): expr =
|
||||
return newCall("foo", newStrLitNode("bar"))
|
||||
result = newCall("foo", newStrLitNode("bar"))
|
||||
|
||||
macro dumpAST(n: stmt): stmt =
|
||||
# dump AST as a side-effect and return the inner node
|
||||
|
||||
@@ -26,7 +26,7 @@ macro formatStyleInterpolation(e: expr): expr =
|
||||
proc addString(s: string) =
|
||||
formatString.add(s)
|
||||
|
||||
proc addExpr(e: expr) =
|
||||
proc addExpr(e: PNimrodNode) =
|
||||
arrayNode.add(e)
|
||||
formatString.add("$" & $(idx))
|
||||
inc idx
|
||||
@@ -44,9 +44,9 @@ macro concatStyleInterpolation(e: expr): expr =
|
||||
var args: seq[PNimrodNode]
|
||||
newSeq(args, 0)
|
||||
|
||||
proc addString(s: string) = args.add(newStrLitNode(s))
|
||||
proc addExpr(e: expr) = args.add(e)
|
||||
proc addDollar() = args.add(newStrLitNode"$")
|
||||
proc addString(s: string) = args.add(newStrLitNode(s))
|
||||
proc addExpr(e: PNimrodNode) = args.add(e)
|
||||
proc addDollar() = args.add(newStrLitNode"$")
|
||||
|
||||
ProcessInterpolations(e)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import
|
||||
# `opened` here could be an overloaded proc which any type can define.
|
||||
# A common practice can be returing an Optional[Resource] obj for which
|
||||
# `opened` is defined to `optional.hasValue`
|
||||
macro using(e: expr) : stmt =
|
||||
macro using(e: expr): stmt =
|
||||
if e.len != 2:
|
||||
error "Using statement: unexpected number of arguments. Got " &
|
||||
$e.len & ", expected: 1 or more variable assignments and a block"
|
||||
@@ -81,7 +81,7 @@ macro using(e: expr) : stmt =
|
||||
targetAst[0][1][1][0] = body
|
||||
targetAst[0][1][1][1][0] = finallyBlock
|
||||
|
||||
return targetAst
|
||||
result = targetAst
|
||||
|
||||
type
|
||||
TResource* = object
|
||||
|
||||
Reference in New Issue
Block a user