Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty PVL enums causing verification failure #1248

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/parsers/vct/parsers/transform/PVLToCol.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ case class PVLToCol[G](

def convert(implicit enum: EnumDeclContext): Enum[G] =
enum match {
case EnumDecl0(_, name, _, constants, _, _) =>
new vct.col.ast.Enum[G](constants.map(convertConstants(_)).getOrElse(
Nil
))(origin(enum).sourceName(convert(name)))
case EnumDecl0(_, name, _, Some(constants), _, _) =>
new vct.col.ast.Enum[G](convertConstants(constants))(origin(enum).sourceName(convert(name)))
case _ =>
fail(enum, "This enumeration must specify at least one constant")
}

def convertConstants(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class Test {
enum AB { A, B }
"""

vercors should error withCode "parseError" in "pvl/empty enum" pvl """
enum E { }
"""

vercors should error withCode "parseError" in "pvl/empty enum with added comma" pvl """
enum E { , }
"""

vercors should verify using silicon in "pvl/enum return" pvl """
enum AB { A, B }

Expand Down
Loading