mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-30 09:54:49 +00:00
bugfix: tests/reject/tnoinst.nim is now rejected properly
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
16
tests/reject/tnoinst.nim
Normal 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]()
|
||||
|
||||
2
todo.txt
2
todo.txt
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user