mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
@@ -535,7 +535,18 @@ proc semArrayConstr(c: PContext, n: PNode, flags: TExprFlags): PNode =
|
||||
result.sons[i] = fitNode(c, typ, result.sons[i])
|
||||
result.typ.sons[0] = makeRangeType(c, 0, sonsLen(result) - 1, n.info)
|
||||
|
||||
template fixAbstractType(c: PContext, n: PNode) =
|
||||
proc fixAbstractType(c: PContext, n: PNode) =
|
||||
for i in 1 .. < n.len:
|
||||
let it = n.sons[i]
|
||||
# do not get rid of nkHiddenSubConv for OpenArrays, the codegen needs it:
|
||||
if it.kind == nkHiddenSubConv and
|
||||
skipTypes(it.typ, abstractVar).kind notin {tyOpenArray, tyVarargs}:
|
||||
if skipTypes(it.sons[1].typ, abstractVar).kind in
|
||||
{tyNil, tyArrayConstr, tyTuple, tySet}:
|
||||
var s = skipTypes(it.typ, abstractVar)
|
||||
if s.kind != tyExpr:
|
||||
changeType(it.sons[1], s, check=true)
|
||||
n.sons[i] = it.sons[1]
|
||||
when false:
|
||||
# XXX finally rewrite that crap!
|
||||
for i in countup(1, sonsLen(n) - 1):
|
||||
@@ -2042,7 +2053,7 @@ proc semExpr(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
|
||||
of nkEmpty, nkNone, nkCommentStmt:
|
||||
discard
|
||||
of nkNilLit:
|
||||
result.typ = getSysType(tyNil)
|
||||
if result.typ == nil: result.typ = getSysType(tyNil)
|
||||
of nkIntLit:
|
||||
if result.typ == nil: setIntLitType(result)
|
||||
of nkInt8Lit:
|
||||
|
||||
@@ -548,7 +548,7 @@ proc foldConv*(n, a: PNode; check = false): PNode =
|
||||
discard
|
||||
else:
|
||||
result = a
|
||||
result.typ = takeType(n.typ, a.typ)
|
||||
result.typ = n.typ
|
||||
|
||||
proc getArrayConstr(m: PSym, n: PNode): PNode =
|
||||
if n.kind == nkBracket:
|
||||
|
||||
20
tests/distinct/tdistinct_consts.nim
Normal file
20
tests/distinct/tdistinct_consts.nim
Normal file
@@ -0,0 +1,20 @@
|
||||
|
||||
# bug #2641
|
||||
|
||||
type MyChar = distinct char
|
||||
const c:MyChar = MyChar('a')
|
||||
|
||||
type MyBool = distinct bool
|
||||
const b:MyBool = MyBool(true)
|
||||
|
||||
type MyBoolSet = distinct set[bool]
|
||||
const bs:MyBoolSet = MyBoolSet({true})
|
||||
|
||||
type MyCharSet= distinct set[char]
|
||||
const cs:MyCharSet = MyCharSet({'a'})
|
||||
|
||||
type MyBoolSeq = distinct seq[bool]
|
||||
const bseq:MyBoolSeq = MyBoolSeq(@[true, false])
|
||||
|
||||
type MyBoolArr = distinct array[3, bool]
|
||||
const barr:MyBoolArr = MyBoolArr([true, false, true])
|
||||
14
tests/template/tdefault_nil.nim
Normal file
14
tests/template/tdefault_nil.nim
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# bug #2629
|
||||
import sequtils, os
|
||||
|
||||
template glob_rst(basedir: string = nil): expr =
|
||||
if baseDir.isNil:
|
||||
to_seq(walk_files("*.rst"))
|
||||
else:
|
||||
to_seq(walk_files(basedir/"*.rst"))
|
||||
|
||||
let
|
||||
rst_files = concat(glob_rst(), glob_rst("docs"))
|
||||
|
||||
when isMainModule: echo rst_files
|
||||
Reference in New Issue
Block a user