fix #188
This commit is contained in:
parent
74f4901430
commit
b80503814d
3 changed files with 45 additions and 1 deletions
|
|
@ -89,6 +89,7 @@ type
|
||||||
errInvalidIndexValueForTuple, errCommandExpectsFilename,
|
errInvalidIndexValueForTuple, errCommandExpectsFilename,
|
||||||
errMainModuleMustBeSpecified,
|
errMainModuleMustBeSpecified,
|
||||||
errXExpected,
|
errXExpected,
|
||||||
|
errTIsNotAConcreteType,
|
||||||
errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
|
errInvalidSectionStart, errGridTableNotImplemented, errGeneralParseError,
|
||||||
errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
|
errNewSectionExpected, errWhitespaceExpected, errXisNoValidIndexFile,
|
||||||
errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitely,
|
errCannotRenderX, errVarVarTypeNotAllowed, errInstantiateXExplicitely,
|
||||||
|
|
@ -312,6 +313,7 @@ const
|
||||||
errCommandExpectsFilename: "command expects a filename argument",
|
errCommandExpectsFilename: "command expects a filename argument",
|
||||||
errMainModuleMustBeSpecified: "please, specify a main module in the project configuration file",
|
errMainModuleMustBeSpecified: "please, specify a main module in the project configuration file",
|
||||||
errXExpected: "\'$1\' expected",
|
errXExpected: "\'$1\' expected",
|
||||||
|
errTIsNotAConcreteType: "\'$1\' is not a concrete type.",
|
||||||
errInvalidSectionStart: "invalid section start",
|
errInvalidSectionStart: "invalid section start",
|
||||||
errGridTableNotImplemented: "grid table is not implemented",
|
errGridTableNotImplemented: "grid table is not implemented",
|
||||||
errGeneralParseError: "general parse error",
|
errGeneralParseError: "general parse error",
|
||||||
|
|
|
||||||
|
|
@ -764,6 +764,28 @@ proc typeSectionRightSidePass(c: PContext, n: PNode) =
|
||||||
s.ast = a
|
s.ast = a
|
||||||
popOwner()
|
popOwner()
|
||||||
|
|
||||||
|
proc checkForMetaFields(n: PNode) =
|
||||||
|
template checkMeta(t) =
|
||||||
|
if t.isMetaType and tfGenericTypeParam notin t.flags:
|
||||||
|
localError(n.info, errTIsNotAConcreteType, t.typeToString)
|
||||||
|
|
||||||
|
case n.kind
|
||||||
|
of nkRecList, nkRecCase:
|
||||||
|
for s in n: checkForMetaFields(s)
|
||||||
|
of nkOfBranch, nkElse:
|
||||||
|
checkForMetaFields(n.lastSon)
|
||||||
|
of nkSym:
|
||||||
|
let t = n.sym.typ
|
||||||
|
case t.kind
|
||||||
|
of tySequence, tySet, tyArray, tyOpenArray, tyVar, tyPtr, tyRef,
|
||||||
|
tyProc, tyGenericInvokation, tyGenericInst:
|
||||||
|
for s in t.sons:
|
||||||
|
checkMeta(s)
|
||||||
|
else:
|
||||||
|
checkMeta(t)
|
||||||
|
else:
|
||||||
|
internalAssert false
|
||||||
|
|
||||||
proc typeSectionFinalPass(c: PContext, n: PNode) =
|
proc typeSectionFinalPass(c: PContext, n: PNode) =
|
||||||
for i in countup(0, sonsLen(n) - 1):
|
for i in countup(0, sonsLen(n) - 1):
|
||||||
var a = n.sons[i]
|
var a = n.sons[i]
|
||||||
|
|
@ -780,6 +802,8 @@ proc typeSectionFinalPass(c: PContext, n: PNode) =
|
||||||
assignType(s.typ, t)
|
assignType(s.typ, t)
|
||||||
s.typ.id = t.id # same id
|
s.typ.id = t.id # same id
|
||||||
checkConstructedType(s.info, s.typ)
|
checkConstructedType(s.info, s.typ)
|
||||||
|
if s.typ.kind in {tyObject, tyTuple}:
|
||||||
|
checkForMetaFields(s.typ.n)
|
||||||
let aa = a.sons[2]
|
let aa = a.sons[2]
|
||||||
if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and
|
if aa.kind in {nkRefTy, nkPtrTy} and aa.len == 1 and
|
||||||
aa.sons[0].kind == nkObjectTy:
|
aa.sons[0].kind == nkObjectTy:
|
||||||
|
|
|
||||||
18
tests/generics/tmetafield.nim
Normal file
18
tests/generics/tmetafield.nim
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
discard """
|
||||||
|
cmd: "nimrod check $# $#"
|
||||||
|
msg: "'proc' is not a concrete type"
|
||||||
|
msg: "'seq[Foo]' is not a concrete type."
|
||||||
|
msg: "invalid type: 'TBaseMed'"
|
||||||
|
"""
|
||||||
|
|
||||||
|
type
|
||||||
|
Foo[T] = object
|
||||||
|
x: T
|
||||||
|
|
||||||
|
TBaseMed = object
|
||||||
|
doSmth: proc
|
||||||
|
data: seq[Foo]
|
||||||
|
|
||||||
|
var a: TBaseMed
|
||||||
|
|
||||||
|
# issue 188
|
||||||
Loading…
Add table
Add a link
Reference in a new issue