Skip to content

Commit

Permalink
Workaround for Nim regression #23112
Browse files Browse the repository at this point in the history
  • Loading branch information
flyx committed Dec 30, 2023
1 parent c7e5a8a commit cdbf426
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion yaml/native.nim
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,12 @@ proc recEnsureAllFieldsPresent(
stmt.add(checkMissing(s, tDecl, tName, child, field, matched, o, m))
inc(field)

proc getTypedescType(t: typedesc): NimNode {.compileTime.} =
## workaround for https://github.com/nim-lang/Nim/issues/23112
result = getType(t)
while result.kind == nnkBracketExpr and result[0].eqIdent"typeDesc":
result = getType(result[1])

macro ensureAllFieldsPresent(
s : YamlStream,
t : typedesc,
Expand Down Expand Up @@ -1436,7 +1442,7 @@ proc isImplicitVariantObject(t: typedesc): bool {.compileTime.} =

proc canBeImplicit(t: typedesc): string {.compileTime.} =
## returns empty string if type can be implicit, else the reason why it can't
let tDesc = getType(t)
let tDesc = getTypedescType(t)
if tDesc.kind != nnkObjectTy: return "type is not an object"
if tDesc[2].len != 1 or tDesc[2][0].kind != nnkRecCase:
return "type doesn't exclusively contain record case"
Expand Down

0 comments on commit cdbf426

Please sign in to comment.