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

[DSLX] can't use parametric constexprs in struct definition #1867

Open
dank-openai opened this issue Jan 17, 2025 · 0 comments
Open

[DSLX] can't use parametric constexprs in struct definition #1867

dank-openai opened this issue Jan 17, 2025 · 0 comments

Comments

@dank-openai
Copy link

dank-openai commented Jan 17, 2025

Describe the bug

I'm unable to do something with parametrics; I think it should be legal. As best as I can tell, the narrowest definition of the bug is: I can't use constexprs in a struct's parametric definitions.

To Reproduce

pub struct FixedPoint<SIGNED:u32, NUM_BITS: u32,  SIGNED_BOOL: bool = {SIGNED > u32:0} > {
    data: xN[SIGNED_BOOL][NUM_BITS],
}

#[test]
fn test_instantiate_FixedPoint() {
    let a = FixedPoint<u32:0, u32:5> { data: u5:1};
    assert_eq(a.data, u5:1);
}

Build and test the above. The error shows up during the test.

Error: INVALID_ARGUMENT: Cannot convert expression to parametric: SIGNED > u32:0================================================================================

Expected behavior
It should work, the test should pass.

Additional context

If you're wondering why I made SIGNED a u32 instead of bool, see this bug.

I find it strange that this error appears at test runtime instead of typechecking.

@dank-openai dank-openai changed the title [DSLX] Cannot convert expression to parametric: SIGNED > u32:0 [DSLX] can't use parametric constexprs in struct definition Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant