You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was attempting to use enumerated arrays to map a constant of one to another value. It works for declaring a value on the stack, but making a poly procedure for it fails. With a little more of an elaborate example, its possible to get the compiler to output Internal Compiler Error: match_exact_values: How'd you get here? Invalid ExactValueKind 8.
Either for it to fully function in all cases, or to gracefully reject.
Current Behavior
It is inconsistent, or crashes the compiler depending on usage.
Failure Information (for bugs)
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
package bug
import"core:fmt"
Dimension :: enum {
D1,
D2,
D3,
}
when#config(BROKEN, false) {
@(private)
DIMENSION_COUNT :: [Dimension]int {
.D1 = 1,
.D2 = 2,
.D3 = 3,
}
// Breaks when the function exists
Image :: struct($DIM: Dimension) {
size: [DIMENSION_COUNT[DIM]]int,
}
} else {
// Works with and without the function existing.
Image :: struct($DIM: Dimension) {
size: [1 + (u32)(DIM)]int,
}
}
create_image :: proc($DIM: Dimension) -> Image(DIM) {
image: Image(DIM)
return image
}
main :: proc() {
image1: Image(.D1)
fmt.println(image1)
image3 := create_image(.D3)
fmt.println(image3)
}
When BROKEN is set to false it will use a working path that casts the enum to u32. When it is true it will break when create_image is defined, but won't have an issue if you comment it and the respective call out.
More elaborate, even more broken code here (txt extension because github wouldn't allow .odin) bug.odin.txt
Failure Logs
For the simpler case:
Error: Array count must be a constant integer
size: [DIMENSION_COUNT[DIM]]int,
For the more elaborate case:
Error: Cannot cast 'DIM' as 'int' from 'Dimension'
size: [1 + (int)(DIM)]int,
^~^
'[View_Type]Dimension{.D1 = .D1, .D1_Array = .D1, .D2 = .D2, .D2_Array = .D2, .D3 = .D3, .Cube = .D2, .Cube_Array = .D2}' cannot be represented as the type 'int'
Internal Compiler Error: match_exact_values: How'd you get here? Invalid ExactValueKind 8
The text was updated successfully, but these errors were encountered:
Context
I was attempting to use enumerated arrays to map a constant of one to another value. It works for declaring a value on the stack, but making a poly procedure for it fails. With a little more of an elaborate example, its possible to get the compiler to output
Internal Compiler Error: match_exact_values: How'd you get here? Invalid ExactValueKind 8
.Odin: dev-2024-08:3847d0324
OS: Windows 11 Home Basic (version: 24H2), build 26200.5001
CPU: AMD Ryzen 7 5700X 8-Core Processor
RAM: 32689 MiB
Backend: LLVM 18.1.8
Expected Behavior
Either for it to fully function in all cases, or to gracefully reject.
Current Behavior
It is inconsistent, or crashes the compiler depending on usage.
Failure Information (for bugs)
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
When
BROKEN
is set tofalse
it will use a working path that casts the enum tou32
. When it istrue
it will break whencreate_image
is defined, but won't have an issue if you comment it and the respective call out.More elaborate, even more broken code here (txt extension because github wouldn't allow .odin)
bug.odin.txt
Failure Logs
For the simpler case:
For the more elaborate case:
The text was updated successfully, but these errors were encountered: