Skip to content

[enhancement] Disambiguate whether configured_value_or is intended to be a global declaration or usage #3922

@mikex-oss

Description

@mikex-oss

What's hard to do? (limit 100 words)

Right now, configured_values are specified that sets a given label anywhere in the DSLX src (even transitively) (edit: this turned out to be incorrect information), which suggest they represent globals like absl flags.

However, configured_value_or can be specified at any scoping and any number of times for the same label. This makes them more like usages of implicitly declared globals, except that the types are not even required to be the same.

E.g. this is fine:

fn foo() -> u2 { configured_value_or<u2>("my_value", 0) }

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

#[test]
fn test_collision() {
    let x = foo();
    let y = bar();
    let z = configured_value_or<u8>("my_value", 0);
    
    assert_eq(x, 1);
    assert_eq(y, 1);
    assert_eq(z, 1);
}

until the value you set is out of range in one of these contexts.

Current best alternative workaround (limit 100 words)

Be careful about reusing configured_value_or labels since DSLX will attempt to set the same value everywhere without warning.

Your view of the "best case XLS enhancement" (limit 100 words)

It seems like either these should have better scoping rules, e.g. configured_values = {"github_issue.foo.my_value": "1", "github_issue.test_collision.my_value": "4"} or we'd benefit from separating things like absl flags.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dslxDSLX (domain specific language) implementation / front-endenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions