Skip to content

results.Opt as object fields could generate codegen issues #142

@cheatfate

Description

@cheatfate

All Nim versions are affected
#141

import stew/results

type
  ValidatorSig = object
    blob: array[96, byte]
  SyncDutyAndProof = object
    slotSig: Opt[ValidatorSig]
const
  DefaultSyncDutyAndProof =
    SyncDutyAndProof(slotSig: Opt.none(ValidatorSig))

echo DefaultSyncDutyAndProof
/home/runner/.cache/nim/all_tests_d/@mtest_results.nim.c:974:143: error: ‘union <anonymous>’ has no member named ‘_o_1’; did you mean ‘_o_2’?
 N_LIB_PRIVATE NIM_CONST tyObject_SyncDutyAndProof__9atwCZvu9aDnhulGNwFXJ9cFg DefaultSyncDutyAndProof__qmlenLhfD5mHF063hF585Q = {{NIM_FALSE, {._o_1 = {}}}
                                                                                                                                               ^~~~
                                                                                                                                               _o_2
                                                                                                                                               

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions