Semfold for nil cast (#16030)

* bring back the semfold of nil

* remove space

* fix test

* proc type can't be dereferenced
This commit is contained in:
cooldome 2020-11-18 17:19:57 +00:00 • committed by GitHub
commit 87d3e5331a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View file

@ -71,8 +71,10 @@ proc genLiteral(p: BProc, n: PNode, ty: PType): Rope =
p.module.s[cfsData].addf(
"static NIM_CONST $1 $2 = {NIM_NIL,NIM_NIL};$n",
[getTypeDesc(p.module, ty), result])
else:
elif k in {tyPointer, tyNil, tyProc}:
result = rope("NIM_NIL")
else:
result = "(($1) NIM_NIL)" % [getTypeDesc(p.module, ty)]
of nkStrLit..nkTripleStrLit:
let k = if ty == nil: tyString
else: skipTypes(ty, abstractVarRange + {tyStatic, tyUserTypeClass, tyUserTypeClassInst}).kind