nimpretty: fixes #11616

This commit is contained in:
Araq 2019-07-18 12:13:22 +02:00
commit 6d8913ee14
3 changed files with 99 additions and 6 deletions

View file

@ -786,3 +786,39 @@ if true:
"foo1", "bar1", "foo2", "bar2", "foo3", "bar3", "foo4", "bar4", "foo5", "bar5", "foo6", "bar6", "foo7",
"zzz", "ggg", "ddd",
]
const b = true
let fooB =
if true:
if b: 7 else: 8
else: ord(b)
let foo = if cond:
if b: T else: F
else: b
let a =
[[aaadsfas, bbb],
[ccc, ddd]]
let b = [
[aaa, bbb],
[ccc, ddd]
]
# bug #11616
proc newRecordGen(ctx: Context; typ: TypRef): PNode =
result = nkTypeDef.t(
newId(typ.optSym.name, true, pragmas = [id(if typ.isUnion: "cUnion"
else: "cStruct")]),
empty(),
nkObjectTy.t(
empty(),
empty(),
nkRecList.t(
typ.recFields.map(newRecFieldGen))))
proc f =
# doesn't break the code, but leaving indentation as is would be nice.
let x = if true: callingProcWhatever()
else: callingADifferentProc()

View file

@ -799,3 +799,39 @@ if true:
"bar5", "foo6", "bar6", "foo7",
"zzz", "ggg", "ddd",
]
const b = true
let fooB =
if true:
if b: 7 else: 8
else: ord(b)
let foo = if cond:
if b: T else: F
else: b
let a =
[[aaadsfas, bbb],
[ccc, ddd]]
let b = [
[aaa, bbb],
[ccc, ddd]
]
# bug #11616
proc newRecordGen(ctx: Context; typ: TypRef): PNode =
result = nkTypeDef.t(
newId(typ.optSym.name, true, pragmas = [id(if typ.isUnion: "cUnion"
else: "cStruct")]),
empty(),
nkObjectTy.t(
empty(),
empty(),
nkRecList.t(
typ.recFields.map(newRecFieldGen))))
proc f =
# doesn't break the code, but leaving indentation as is would be nice.
let x = if true: callingProcWhatever()
else: callingADifferentProc()