diff options
author | Arne Döring <arne.doering@gmx.net> | 2019-08-06 01:26:53 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-08-06 01:26:53 +0200 |
commit | ce148e71ef49dab3d8e61499bce40fd5718ecff4 (patch) | |
tree | bcbe4a2fe7bf453dba5bce2dcc4da341899fb4e8 /compiler | |
parent | 42e83ac24ccdbc79612be2e0611ce7c82c38e8e1 (diff) | |
download | Nim-ce148e71ef49dab3d8e61499bce40fd5718ecff4.tar.gz |
disallow static in return type (#9686) [nobackport]
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/semtypes.nim | 3 | ||||
-rw-r--r-- | compiler/types.nim | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index 3bc2f4ede..a2425e9fa 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1230,6 +1230,9 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, # 'p(): auto' and 'p(): expr' are equivalent, but the rest of the # compiler is hardly aware of 'auto': r = newTypeS(tyUntyped, c) + elif r.kind == tyStatic: + # type allowed should forbid this type + discard else: if r.sym == nil or sfAnon notin r.sym.flags: let lifted = liftParamType(c, kind, genericParams, r, "result", diff --git a/compiler/types.nim b/compiler/types.nim index e41f45780..20f0d516e 100644 --- a/compiler/types.nim +++ b/compiler/types.nim @@ -1238,7 +1238,9 @@ proc typeAllowedAux(marker: var IntSet, typ: PType, kind: TSymKind, of tyTypeDesc: # XXX: This is still a horrible idea... result = nil - of tyUntyped, tyTyped, tyStatic: + of tyStatic: + if kind notin {skParam}: result = t + of tyUntyped, tyTyped: if kind notin {skParam, skResult}: result = t of tyVoid: if taField notin flags: result = t |