Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
krux02 committed Nov 8, 2018
1 parent a0e89bd commit 3cbb8e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/ccgtypes.nim
Expand Up @@ -146,6 +146,8 @@ proc mapType(conf: ConfigRef; typ: PType): TCTypeKind =
return mapType(conf, typ.lastSon)
of tyGenericBody, tyGenericInst, tyGenericParam, tyDistinct, tyOrdinal,
tyTypeDesc, tyAlias, tySink, tyInferred:
if typ.sons.len == 0:
internalError(conf, "typ has no last son")
result = mapType(conf, lastSon(typ))
of tyEnum:
if firstOrd(conf, typ) < 0:
Expand Down
6 changes: 5 additions & 1 deletion compiler/semstmts.nim
Expand Up @@ -41,8 +41,12 @@ proc semDiscard(c: PContext, n: PNode): PNode =
checkSonsLen(n, 1, c.config)
if n.sons[0].kind != nkEmpty:
n.sons[0] = semExprWithType(c, n.sons[0])
if isEmptyType(n.sons[0].typ) or n.sons[0].typ.kind == tyNone or n.sons[0].kind == nkTypeOfExpr:
let sonType = n.sons[0].typ
if isEmptyType(sonType) or sonType.kind == tyNone or n.sons[0].kind == nkTypeOfExpr:
localError(c.config, n.info, errInvalidDiscard)
if sonType.kind == tyProc:
# tyProc is disallowed to prevent ``discard foo`` to pass, when ``discard foo()`` is meant.
localError(c.config, n.info, "illegal discard proc, did you mean: " & $n[0] & "()")

proc semBreakOrContinue(c: PContext, n: PNode): PNode =
result = n
Expand Down

0 comments on commit 3cbb8e8

Please sign in to comment.