diff --git a/yaml/parser.nim b/yaml/parser.nim index 8c61773..6844076 100644 --- a/yaml/parser.nim +++ b/yaml/parser.nim @@ -414,6 +414,8 @@ macro parserState(name: untyped, impl: untyped): typed = nameId = newIdentNode("state" & capitalize(nameStr)) var procImpl = quote do: debug("state: " & `nameStr`) + if procImpl.kind == nnkStmtList and procImpl.len == 1: procImpl = procImpl[0] + procImpl = newStmtList(procImpl) procImpl.add(newLetStmt(ident("c"), newCall("ParserContext", ident("s")))) procImpl.add(newAssignment(newIdentNode("result"), newLit(false))) assert impl.kind == nnkStmtList diff --git a/yaml/serialization.nim b/yaml/serialization.nim index a57aec4..3336625 100644 --- a/yaml/serialization.nim +++ b/yaml/serialization.nim @@ -678,6 +678,8 @@ proc ifNotTransient(tSym: NimNode, fieldIndex: int, content: openarray[NimNode], result = quote do: when `tSym` == -1 or `fieldIndex` notin transientVectors[`tSym`]: `stmts` + if result.kind == nnkStmtList and result.len == 1: result = result[0] + result = newStmtList(result) if elseError: result[0].add(newNimNode(nnkElse).add(quote do: raise constructionError(`s`, "While constructing " & `tName` & @@ -692,6 +694,8 @@ macro ensureAllFieldsPresent(s: YamlStream, t: typedesc, tIndex: int, o: typed, result = quote do: when compiles(`dbp`(`t`)): const `defaultValues` = `defaultValueGetter`(`t`) + if result.kind == nnkStmtList and result.len == 1: result = result[0] + result = newStmtList(result) let tDecl = getType(t) tName = $tDecl[1]