Reject ptr/ref void types (#8127)
Do this during the semantic pass to avoid tripping the following passes. Fixes #6454
This commit is contained in:
parent
5ac74da926
commit
7f148838a4
2 changed files with 10 additions and 0 deletions
|
|
@ -177,6 +177,9 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
|
||||||
var t = semTypeNode(c, n.lastSon, nil)
|
var t = semTypeNode(c, n.lastSon, nil)
|
||||||
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
|
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
|
||||||
t = t.base
|
t = t.base
|
||||||
|
if t.kind == tyVoid:
|
||||||
|
const kindToStr: array[tyPtr..tyRef, string] = ["ptr", "ref"]
|
||||||
|
localError(c.config, n.info, "type '$1 void' is not allowed" % kindToStr[kind])
|
||||||
result = newOrPrevType(kind, prev, c)
|
result = newOrPrevType(kind, prev, c)
|
||||||
var isNilable = false
|
var isNilable = false
|
||||||
# check every except the last is an object:
|
# check every except the last is an object:
|
||||||
|
|
|
||||||
7
tests/types/t6456.nim
Normal file
7
tests/types/t6456.nim
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
discard """
|
||||||
|
line: 6
|
||||||
|
errormsg: "type \'ptr void\' is not allowed"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc foo(x: ptr void) =
|
||||||
|
discard
|
||||||
Loading…
Add table
Add a link
Reference in a new issue