bugfix: tests/reject/tnoinst.nim is now rejected properly
This commit is contained in:
parent
76886432da
commit
e362cbbfd7
5 changed files with 27 additions and 2 deletions
|
|
@ -1022,3 +1022,9 @@ proc getStrOrChar*(a: PNode): string =
|
||||||
internalError(a.info, "getStrOrChar")
|
internalError(a.info, "getStrOrChar")
|
||||||
result = ""
|
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,
|
errInvalidIndexValueForTuple, errCommandExpectsFilename, errXExpected,
|
||||||
errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
|
errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
|
||||||
errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
|
errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
|
||||||
errCannotRenderX, errVarVarTypeNotAllowed,
|
errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitely,
|
||||||
|
|
||||||
errXExpectsTwoArguments,
|
errXExpectsTwoArguments,
|
||||||
errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations,
|
errXExpectsObjectTypes, errXcanNeverBeOfThisSubtype, errTooManyIterations,
|
||||||
|
|
@ -306,6 +306,7 @@ const
|
||||||
errXisNoValidIndexFile: "\'$1\' is no valid index file",
|
errXisNoValidIndexFile: "\'$1\' is no valid index file",
|
||||||
errCannotRenderX: "cannot render reStructuredText element \'$1\'",
|
errCannotRenderX: "cannot render reStructuredText element \'$1\'",
|
||||||
errVarVarTypeNotAllowed: "type \'var var\' is not allowed",
|
errVarVarTypeNotAllowed: "type \'var var\' is not allowed",
|
||||||
|
errInstantiateXExplicitely: "instantiate '$1' explicitely",
|
||||||
errXExpectsTwoArguments: "\'$1\' expects two arguments",
|
errXExpectsTwoArguments: "\'$1\' expects two arguments",
|
||||||
errXExpectsObjectTypes: "\'$1\' expects object types",
|
errXExpectsObjectTypes: "\'$1\' expects object types",
|
||||||
errXcanNeverBeOfThisSubtype: "\'$1\' can never be of this subtype",
|
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:
|
smoduleId != c.module.id and smoduleId != c.friendModule.id:
|
||||||
LocalError(n.info, errXCannotBePassedToProcVar, s.name.s)
|
LocalError(n.info, errXCannotBePassedToProcVar, s.name.s)
|
||||||
result = symChoice(c, n, s)
|
result = symChoice(c, n, s)
|
||||||
|
if result.kind == nkSym and isGenericRoutine(result.sym):
|
||||||
|
LocalError(n.info, errInstantiateXExplicitely, s.name.s)
|
||||||
of skConst:
|
of skConst:
|
||||||
markUsed(n, s)
|
markUsed(n, s)
|
||||||
case skipTypes(s.typ, abstractInst).kind
|
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)
|
- bug: stress testing basic method example (eval example)
|
||||||
without ``-d:release`` leaks memory; good way to figure out how a
|
without ``-d:release`` leaks memory; good way to figure out how a
|
||||||
fixed amount of stack can hold an arbitrary number of GC roots!
|
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
|
- bug: tsortdev does not run
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue