Skip to content

configured_value_or bool/u1 with integer configured value always treated as 0/false #3923

@mikex-oss

Description

@mikex-oss

Describe the bug
If you try to set a configured_value_or<u1> (or equivalently configured_value_or<bool>), any integer value setting seems to be interpreted as 0.

To Reproduce

fn foo() -> bool { configured_value_or<bool>("my_value", 1) }

fn bar() -> u1 { configured_value_or<u1>("my_value", 0) }

fn baz() -> bool { 1 }

#[test]
fn test_collision() {
    let x = foo();
    let y = bar();
    let z = baz();
    assert_eq(x, 0);
    assert_eq(y, 0);
    assert_eq(z, 1);
}

with configured_values = {"my_value": "1"} or configured_values = {"my_value": "123"} will pass all assertions. x/foo indicates that it's not just ignoring the value and using a default.

Expected behavior
I would expect all functions to return 1 when set to "1" and generate a type inference error like TypeInferenceError: size mismatch: u7 vs. bool when set to "123".

Metadata

Metadata

Assignees

Labels

bugSomething isn't working or is incorrectdslxDSLX (domain specific language) implementation / front-end

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions