Skip to content

Commit

Permalink
Reject ptr/ref void types
Browse files Browse the repository at this point in the history
Do this during the semantic pass to avoid tripping the following passes.

Fixes nim-lang#6454
  • Loading branch information
LemonBoy committed Jun 27, 2018
1 parent 5976bd9 commit a68ef7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ proc semAnyRef(c: PContext; n: PNode; kind: TTypeKind; prev: PType): PType =
var t = semTypeNode(c, n.lastSon, nil)
if t.kind == tyTypeDesc and tfUnresolved notin t.flags:
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)
var isNilable = false
# check every except the last is an object:
Expand Down
7 changes: 7 additions & 0 deletions tests/types/t6456.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
discard """
line: 6
errormsg: "type \'ptr void\' is not allowed"
"""

proc foo(x: ptr void) =
discard

0 comments on commit a68ef7d

Please sign in to comment.