Skip to content

Commit

Permalink
pull in some diffs from pr nim-lang#17706
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed Apr 13, 2021
1 parent 5439e29 commit 73c7f61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ var

type
TMagic* = enum # symbols that require compiler magic:
# see also: magicsAfterOverloadResolution, getConstExpr, semMagic
mNone,
mDefined, mDeclared, mDeclaredInScope, mCompiles, mArrGet, mArrPut, mAsgn,
mLow, mHigh, mSizeOf, mAlignOf, mOffsetOf, mTypeTrait,
Expand Down
8 changes: 4 additions & 4 deletions compiler/importer.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import
intsets, ast, astalgo, msgs, options, idents, lookups,
semdata, modulepaths, sigmatch, lineinfos, sets,
modulegraphs
modulegraphs, wordrecg

proc readExceptSet*(c: PContext, n: PNode): IntSet =
assert n.kind in {nkImportExceptStmt, nkExportExceptStmt}
Expand Down Expand Up @@ -83,7 +83,7 @@ proc rawImportSymbol(c: PContext, s, origin: PSym; importSet: var IntSet) =
else:
importSet.incl s.id
if s.kind == skType:
var etyp = s.typ
let etyp = s.typ
if etyp.kind in {tyBool, tyEnum}:
for j in 0..<etyp.n.len:
var e = etyp.n[j].sym
Expand Down Expand Up @@ -253,7 +253,7 @@ proc myImportModule(c: PContext, n: PNode; importStmtResult: PNode): PSym =
#newStrNode(toFullPath(c.config, f), n.info)

proc transformImportAs(c: PContext; n: PNode): PNode =
if n.kind == nkInfix and considerQuotedIdent(c, n[0]).s == "as":
if n.kind == nkInfix and considerQuotedIdent(c, n[0]).s == $wAs:
result = newNodeI(nkImportAs, n.info)
result.add n[1]
result.add n[2]
Expand Down Expand Up @@ -282,7 +282,7 @@ proc evalImport*(c: PContext, n: PNode): PNode =
imp.add sep # dummy entry, replaced in the loop
for x in it[2]:
# transform `a/b/[c as d]` to `/a/b/c as d`
if x.kind == nkInfix and x[0].ident.s == "as":
if x.kind == nkInfix and x[0].ident.s == $wAs:
let impAs = copyTree(x)
imp[2] = x[1]
impAs[1] = imp
Expand Down
3 changes: 3 additions & 0 deletions compiler/magicsys.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ proc sysTypeFromName*(g: ModuleGraph; info: TLineInfo; name: string): PType =
result = getSysSym(g, info, name).typ

proc getSysType*(g: ModuleGraph; info: TLineInfo; kind: TTypeKind): PType =
# `info` is only used for error reporting.
# xxx instead, use something like `lastInfo`.
template sysTypeFromName(s: string): untyped = sysTypeFromName(g, info, s)
result = g.sysTypes[kind]
if result == nil:
case kind
of tyVoid: result = sysTypeFromName("void")
of tyInt: result = sysTypeFromName("int")
of tyInt8: result = sysTypeFromName("int8")
of tyInt16: result = sysTypeFromName("int16")
Expand Down
2 changes: 1 addition & 1 deletion compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ proc semOperand(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
localError(c.config, n.info, errProcHasNoConcreteType % n.renderTree)
if result.typ.kind in {tyVar, tyLent}: result = newDeref(result)
elif {efWantStmt, efAllowStmt} * flags != {}:
result.typ = newTypeS(tyVoid, c)
result.typ = getSysType(c.graph, n.info, tyVoid)
else:
localError(c.config, n.info, errExprXHasNoType %
renderTree(result, {renderNoComments}))
Expand Down

0 comments on commit 73c7f61

Please sign in to comment.