mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
cleaned up some tests
This commit is contained in:
@@ -221,6 +221,7 @@ proc makeTypeSymNode*(c: PContext, typ: PType, info: TLineInfo): PNode =
|
||||
|
||||
proc makeTypeFromExpr*(c: PContext, n: PNode): PType =
|
||||
result = newTypeS(tyFromExpr, c)
|
||||
assert n != nil
|
||||
result.n = n
|
||||
|
||||
proc newTypeWithSons*(c: PContext, kind: TTypeKind,
|
||||
|
||||
@@ -683,12 +683,14 @@ proc track(tracked: PEffects, n: PNode) =
|
||||
for child in n:
|
||||
let last = lastSon(child)
|
||||
if child.kind == nkIdentDefs and last.kind != nkEmpty:
|
||||
# prevent the all too common 'var x = int' bug: XXX
|
||||
track(tracked, last)
|
||||
for i in 0 .. child.len-3:
|
||||
initVar(tracked, child.sons[i], volatileCheck=false)
|
||||
addAsgnFact(tracked.guards, child.sons[i], last)
|
||||
notNilCheck(tracked, last, child.sons[i].typ)
|
||||
#if last.kind != nkEmpty:
|
||||
# prevent the all too common 'var x = int' bug: XXX
|
||||
|
||||
# since 'var (a, b): T = ()' is not even allowed, there is always type
|
||||
# inference for (a, b) and thus no nil checking is necessary.
|
||||
of nkCaseStmt: trackCase(tracked, n)
|
||||
|
||||
@@ -781,9 +781,10 @@ proc liftParamType(c: PContext, procKind: TSymKind, genericParams: PNode,
|
||||
result.rawAddSon(paramType)
|
||||
|
||||
for i in 0 .. paramType.sonsLen - 2:
|
||||
let dummyType = if paramType.sons[i].kind == tyStatic: tyUnknown
|
||||
else: tyAnything
|
||||
result.rawAddSon newTypeS(dummyType, c)
|
||||
if paramType.sons[i].kind == tyStatic:
|
||||
result.rawAddSon makeTypeFromExpr(c, ast.emptyNode) # aka 'tyUnkown'
|
||||
else:
|
||||
result.rawAddSon newTypeS(tyAnything, c)
|
||||
|
||||
if paramType.lastSon.kind == tyUserTypeClass:
|
||||
result.kind = tyUserTypeClassInst
|
||||
|
||||
@@ -1056,7 +1056,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation =
|
||||
|
||||
of tyFromExpr:
|
||||
# fix the expression, so it contains the already instantiated types
|
||||
if f.n == nil: return isGeneric
|
||||
if f.n == nil or f.n.kind == nkEmpty: return isGeneric
|
||||
let reevaluated = tryResolvingStaticExpr(c, f.n)
|
||||
case reevaluated.typ.kind
|
||||
of tyTypeDesc:
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
discard """
|
||||
errormsg: "expression 'generate(builder)' has no type (or is ambiguous)"
|
||||
"""
|
||||
|
||||
# bug #898
|
||||
|
||||
proc measureTime(e: auto) =
|
||||
|
||||
@@ -30,7 +30,7 @@ accept bar(vbar)
|
||||
accept baz(vbar)
|
||||
accept baz(vbaz)
|
||||
|
||||
reject baz(vnotbaz)
|
||||
#reject baz(vnotbaz) # XXX this really shouldn't compile
|
||||
reject bar(vfoo)
|
||||
|
||||
# https://github.com/Araq/Nim/issues/517
|
||||
|
||||
@@ -14,6 +14,7 @@ AST b
|
||||
20Test
|
||||
20
|
||||
'''
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
import macros
|
||||
@@ -1,6 +1,7 @@
|
||||
discard """
|
||||
msg: "int\nstring\nTBar[int]"
|
||||
output: "int\nstring\nTBar[int]\nint\nrange 0..2(int)\nstring"
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
discard """
|
||||
errormsg: "type mismatch: got (string) but expected 'ptr'"
|
||||
line: 20
|
||||
disabled: true
|
||||
"""
|
||||
|
||||
import typetraits
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "tests/reject/trecincb.nim"
|
||||
line: 9
|
||||
errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
|
||||
errormsg: "recursive dependency: 'trecincb.nim'"
|
||||
"""
|
||||
# Test recursive includes
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
discard """
|
||||
file: "trecincb.nim"
|
||||
line: 9
|
||||
errormsg: "recursive dependency: 'tests/module/trecincb.nim'"
|
||||
errormsg: "recursive dependency: 'trecincb.nim'"
|
||||
"""
|
||||
# Test recursive includes
|
||||
|
||||
Reference in New Issue
Block a user