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

constant vectors not considered to be a compile time constant #1574

Closed
Book-reader opened this issue Oct 26, 2024 · 4 comments
Closed

constant vectors not considered to be a compile time constant #1574

Book-reader opened this issue Oct 26, 2024 · 4 comments
Assignees
Labels
Fixed Needs Verification Fixed, but needs verification that it works
Milestone

Comments

@Book-reader
Copy link
Contributor

Book-reader commented Oct 26, 2024

in the following example:

fn void main()
{
  int[<2>] $test = {3, 3};
  int[<2>] $test2 = {4, 4};
  $if ($test2 == $test):
  $endif
}

the compiler gives the error Error: Compile time evaluation requires a compile time constant value.

the same happens when the variables are declared as global constants using const

$if($test2.x == $test.x) gives the same error but $if($test2[0] == $test[0]) works.

@Book-reader Book-reader changed the title $if does not consider swizzled values from a vector a compile time constant $if does not consider vectors to be a compile time constant Oct 26, 2024
@Book-reader Book-reader changed the title $if does not consider vectors to be a compile time constant constant vectors not considered to be a compile time constant Oct 26, 2024
@lerno
Copy link
Collaborator

lerno commented Oct 26, 2024

That $test2.x isn't compile-time is a bug. That vectors don't fold at compile time is a deliberate simplification.

@lerno lerno self-assigned this Oct 26, 2024
@lerno lerno added Bug Something isn't working Fixed Needs Verification Fixed, but needs verification that it works labels Oct 26, 2024
@lerno
Copy link
Collaborator

lerno commented Oct 26, 2024

The $foo.x issue should be fixed now. I am very hesitant to do compile time evaluation to composite objects beyond element folding.

@lerno lerno added this to the 0.6.4 milestone Oct 26, 2024
@lerno
Copy link
Collaborator

lerno commented Oct 26, 2024

You can still add an enhancement request for at least comparison for constant vectors.

@Book-reader
Copy link
Contributor Author

$foo.x does indeed work now, thanks!

@lerno lerno removed the Bug Something isn't working label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fixed Needs Verification Fixed, but needs verification that it works
Projects
None yet
Development

No branches or pull requests

2 participants