Skip to content

ProveField warning with nested case object #22791

@etan-status

Description

@etan-status

Description

When case objects are nested, there is no way to access the inner fields without triggering ProveField (if enabled)

{.push warning[ProveField]:on.}

type Foo = object
  case a: bool
  of false:
    discard
  of true:
    case b: bool
    of false:
      discard
    of true:
      c: bool

const f = Foo(a: true, b: true, c: true)
case f.a
of true:
  case f.b
  of true:
    echo f.c
  else: discard
else: discard

Nim Version

Nim Compiler Version 2.0.1 [MacOSX: amd64]
Compiled at 2023-10-03
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: d30565f810ba5165ea2e5bcd91ea3dee9950051f
active boot switches: -d:release

Current Output

/Users/etan/Documents/Repos/nimbus-eth2/test.nim(17, 9) Warning: cannot prove that field 'f.b' is accessible [ProveField]
    case f.b
          ^

Expected Output

No warning

Possible Solution

No response

Additional Information

No response

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