Description
Describe the bug
If the input argument is an enum
, then when the falsifying example is reported, it segfaults on ValueToInterpValue
[ RUN QUICKCHECK ] blue_is_always_favorite count: 1000
*** SIGSEGV (@0x8), ... received by PID 929 (TID 929) on cpu 29; stack trace: ***
PC: @ 0x5570f910052d (unknown) xls::dslx::ValueToInterpValue()
@ 0x5570fc25f021 1888 FailureSignalHandler()
@ 0x7fc603949e80 (unknown) (unknown)
@ 0x5570f910052d 368 xls::dslx::ValueToInterpValue()
@ 0x5570f8fbd40b 2096 xls::dslx::AbstractTestRunner::ParseAndTest()
@ 0x5570f8f85cd9 1232 main
@ 0x7fc6037da3d4 192 __libc_start_main
@ 0x5570f8f8402a (unknown) _start
E1113 19:29:42.758104 929 process_state.cc:806] RAW: Raising signal 11 with default behavior
To Reproduce
Steps to reproduce the behavior:
enum Color : u2 {
White = u2:0,
Red = u2:1,
Green = u2:2,
Blue = u2:3,
}
fn favorite_color(color: Color) -> Color { Color::Blue }
#[quickcheck]
fn blue_is_always_favorite(color: Color) -> bool { favorite_color(color) == Color::White }
Expected behavior
The quickcheck should properly report the falsifying sample when found.
As a workaround, you can use u2
as the input type for the quickcheck arg, and then cast to the enum, i.e.
enum Color : u2 {
White = u2:0,
Red = u2:1,
Green = u2:2,
Blue = u2:3,
}
fn favorite_color(color: Color) -> Color { Color::Blue }
#[quickcheck]
fn blue_is_always_favorite(color: u2) -> bool { favorite_color(color as Color) == Color::White }
will properly report:
FailureError: The program being interpreted failed! Found falsifying example after 1 tests: [u2:2]
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done