mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-15 07:43:26 +00:00
made tests green again
This commit is contained in:
@@ -1427,7 +1427,7 @@ proc buildCall(n: PNode): PNode =
|
||||
elif n.kind in nkCallKinds and n.sons[0].kind == nkDotExpr:
|
||||
# x.y(a) -> y(x, a)
|
||||
let a = n.sons[0]
|
||||
result = newNodeI(nkDotCall, n.info, n.len+1)
|
||||
result = newNodeI(nkCall, n.info, n.len+1)
|
||||
result.sons[0] = a.sons[1]
|
||||
result.sons[1] = a.sons[0]
|
||||
for i in 1 .. <n.len: result.sons[i+1] = n.sons[i]
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
type
|
||||
TSemGenericFlag = enum
|
||||
withinBind, withinTypeDesc
|
||||
withinBind, withinTypeDesc, withinMixin
|
||||
TSemGenericFlags = set[TSemGenericFlag]
|
||||
|
||||
proc getIdentNode(n: PNode): PNode =
|
||||
@@ -80,13 +80,15 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||
of nkIdent, nkAccQuoted:
|
||||
var s = SymtabGet(c.Tab, n.ident)
|
||||
if s == nil:
|
||||
localError(n.info, errUndeclaredIdentifier, n.ident.s)
|
||||
if withinMixin notin flags:
|
||||
localError(n.info, errUndeclaredIdentifier, n.ident.s)
|
||||
else:
|
||||
if withinBind in flags or s.id in toBind:
|
||||
result = symChoice(c, n, s, scClosed)
|
||||
else: result = semGenericStmtSymbol(c, n, s)
|
||||
of nkDotExpr:
|
||||
var s = QualifiedLookUp(c, n, {checkUndeclared})
|
||||
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
||||
var s = QualifiedLookUp(c, n, luf)
|
||||
if s != nil: result = semGenericStmtSymbol(c, n, s)
|
||||
# XXX for example: ``result.add`` -- ``add`` needs to be looked up here...
|
||||
of nkEmpty, nkSym..nkNilLit:
|
||||
@@ -98,7 +100,8 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||
of nkCall, nkHiddenCallConv, nkInfix, nkPrefix, nkCommand, nkCallStrLit:
|
||||
# check if it is an expression macro:
|
||||
checkMinSonsLen(n, 1)
|
||||
var s = qualifiedLookup(c, n.sons[0], {checkUndeclared})
|
||||
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
||||
var s = qualifiedLookup(c, n.sons[0], luf)
|
||||
var first = 0
|
||||
var isDefinedMagic = false
|
||||
if s != nil:
|
||||
@@ -143,7 +146,8 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||
var a: PNode
|
||||
if isCallExpr(n.sons[0]): a = n.sons[0].sons[0]
|
||||
else: a = n.sons[0]
|
||||
var s = qualifiedLookup(c, a, {checkUndeclared})
|
||||
let luf = if withinMixin notin flags: {checkUndeclared} else: {}
|
||||
var s = qualifiedLookup(c, a, luf)
|
||||
if s != nil and macroToExpand(s):
|
||||
result = semMacroStmt(c, n, {}, false)
|
||||
for i in countup(0, sonsLen(result)-1):
|
||||
@@ -151,6 +155,9 @@ proc semGenericStmt(c: PContext, n: PNode,
|
||||
of nkIfStmt:
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
n.sons[i] = semGenericStmtScope(c, n.sons[i], flags, toBind)
|
||||
of nkWhenStmt:
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
n.sons[i] = semGenericStmt(c, n.sons[i], flags+{withinMixin}, toBind)
|
||||
of nkWhileStmt:
|
||||
openScope(c.tab)
|
||||
for i in countup(0, sonsLen(n)-1):
|
||||
|
||||
@@ -41,7 +41,7 @@ proc binarySearch*[T](a: openarray[T], key: T): int =
|
||||
var mid = (result + b) div 2
|
||||
if a[mid] < key: result = mid + 1
|
||||
else: b = mid
|
||||
if result >= len(x) or a[result] != key: result = -1
|
||||
if result >= len(a) or a[result] != key: result = -1
|
||||
|
||||
proc smartBinarySearch*[T](a: openArray[T], key: T): int =
|
||||
## ``a.len`` must be a power of 2 for this to work.
|
||||
|
||||
@@ -1673,6 +1673,10 @@ template newException*(exceptn: typeDesc, message: string): expr =
|
||||
e.msg = message
|
||||
e
|
||||
|
||||
proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo".}
|
||||
## get type information for `x`. Ordinary code should not use this, but
|
||||
## the `typeinfo` module instead.
|
||||
|
||||
when not defined(EcmaScript) and not defined(NimrodVM):
|
||||
{.push stack_trace: off, profiler:off.}
|
||||
|
||||
@@ -2201,10 +2205,6 @@ proc `[]=`*[T](s: var seq[T], x: TSlice[int], b: openArray[T]) =
|
||||
for i in 0 .. <L: s[i+a] = b[i]
|
||||
else:
|
||||
spliceImpl(s, a, L, b)
|
||||
|
||||
proc getTypeInfo*[T](x: T): pointer {.magic: "GetTypeInfo".}
|
||||
## get type information for `x`. Ordinary code should not use this, but
|
||||
## the `typeinfo` module instead.
|
||||
|
||||
proc slurp*(filename: string): string {.magic: "Slurp".}
|
||||
proc staticRead*(filename: string): string {.magic: "Slurp".}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
file: "system.nim"
|
||||
line: 646
|
||||
line: 643
|
||||
errormsg: "type mismatch"
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user