bugfix: tests/reject/tnoinst.nim is now rejected properly

This commit is contained in:
Araq
2012-01-13 13:40:05 +01:00
parent 76886432da
commit e362cbbfd7
5 changed files with 27 additions and 2 deletions

View File

@@ -1022,3 +1022,9 @@ proc getStrOrChar*(a: PNode): string =
internalError(a.info, "getStrOrChar")
result = ""
proc isGenericRoutine*(s: PSym): bool =
case s.kind
of skProc, skTemplate, skMacro, skIterator:
result = s.ast != nil and s.ast[genericParamsPos].kind != nkEmpty
else: nil

View File

@@ -85,7 +85,7 @@ type
errInvalidIndexValueForTuple, errCommandExpectsFilename, errXExpected,
errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
errCannotRenderX, errVarVarTypeNotAllowed,
errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitely,
errXExpectsTwoArguments,
errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations,
@@ -306,6 +306,7 @@ const
errXisNoValidIndexFile: "\'$1\' is no valid index file",
errCannotRenderX: "cannot render reStructuredText element \'$1\'",
errVarVarTypeNotAllowed: "type \'var var\' is not allowed",
errInstantiateXExplicitely: "instantiate '$1' explicitely",
errXExpectsTwoArguments: "\'$1\' expects two arguments",
errXExpectsObjectTypes: "\'$1\' expects object types",
errXcanNeverBeOfThisSubtype: "\'$1\' can never be of this subtype",

View File

@@ -58,6 +58,8 @@ proc semSym(c: PContext, n: PNode, s: PSym, flags: TExprFlags): PNode =
smoduleId != c.module.id and smoduleId != c.friendModule.id:
LocalError(n.info, errXCannotBePassedToProcVar, s.name.s)
result = symChoice(c, n, s)
if result.kind == nkSym and isGenericRoutine(result.sym):
LocalError(n.info, errInstantiateXExplicitely, s.name.s)
of skConst:
markUsed(n, s)
case skipTypes(s.typ, abstractInst).kind

16
tests/reject/tnoinst.nim Normal file
View File

@@ -0,0 +1,16 @@
discard """
line: 12
errormsg: "instantiate 'notConcrete' explicitely"
"""
proc wrap[T]() =
proc notConcrete[T](x, y: int): int =
var dummy: T
result = x - y
var x: proc (x, y: T): int
x = notConcrete
wrap[int]()

View File

@@ -44,7 +44,7 @@ Bugs
- bug: stress testing basic method example (eval example)
without ``-d:release`` leaks memory; good way to figure out how a
fixed amount of stack can hold an arbitrary number of GC roots!
- BUG: temp2.nim triggers weird compiler and except.nim bug
- bug: temp2.nim triggers weird compiler and except.nim bug
- bug: tsortdev does not run