Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Nov 17, 2020
1 parent 9a5815e commit e00305b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ const
errNoGenericParamsAllowedForX = "no generic parameters allowed for $1"
errInOutFlagNotExtern = "the '$1' modifier can be used only with imported types"


proc isDiscardUnderscoreV(v: PSym): bool =
if v.name.s == "_":
v.flags.incl(sfGenSym)
result = true

proc newOrPrevType(kind: TTypeKind, prev: PType, c: PContext): PType =
if prev == nil:
result = newTypeS(kind, c)
Expand Down Expand Up @@ -978,7 +984,9 @@ proc addParamOrResult(c: PContext, param: PSym, kind: TSymKind) =
# bug #XXX, fix the gensym'ed parameters owner:
if param.owner == nil:
param.owner = getCurrOwner(c)
else: addDecl(c, param)
else:
if not isDiscardUnderscoreV(param):
addDecl(c, param)

template shouldHaveMeta(t) =
internalAssert c.config, tfHasMeta in t.flags
Expand Down Expand Up @@ -1280,8 +1288,10 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode,
inc(counter)
if def != nil and def.kind != nkEmpty:
arg.ast = copyTree(def)
if containsOrIncl(check, arg.name.id):
localError(c.config, a[j].info, "attempt to redefine: '" & arg.name.s & "'")
# addDecl
if not isDiscardUnderscoreV(arg):
if containsOrIncl(check, arg.name.id):
localError(c.config, a[j].info, "attempt to redefine: '" & arg.name.s & "'")
result.n.add newSymNode(arg)
rawAddSon(result, finalType)
addParamOrResult(c, arg, kind)
Expand Down

0 comments on commit e00305b

Please sign in to comment.