Odin
Odin copied to clipboard
matrix type cannot be used in parapoly
Context
Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.
- Operating System & Odin Version:
- Please paste
odin reportoutput:
Odin: dev-2023-11:04244041
OS: Ubuntu 22.04.3 LTS, Linux 5.15.133.1-microsoft-standard-WSL2
CPU: 12th Gen Intel(R) Core(TM) i7-12700H
RAM: 15838 MiB
Expected Behavior
Please describe the behavior you are expecting
field_matrix :: proc(
$N: int,
) -> (
result: matrix[N, N]int,
) {
return
}
or
field_matrix :: proc(
$N: int,
) -> (
result: matrix[N, N]int,
) where N <= 4 {
return
}
should both work. The following without matrix however does work
field_matrix :: proc(
$N: int,
) -> (
result: [N][N]int,
) {
return
}
works
Current Behavior
compiler would complain
Error: Invalid matrix row count, expected 1+ rows, got N
) -> matrix[N, N]int {
Error: Invalid matrix column count, expected 1+ rows, got N
) -> matrix[N, N]int {
Failure Information (for bugs)
Please help provide information about the failure if this is a bug. If it is not a bug, please remove the rest of this template.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
- Use matrix in parapoly function declaration
- Compile
- Won't compile
Failure Logs
Please include any relevant log snippets or files here.
I also found that the following is allowed, so it seems that this bug only happens inside the declaration
field_matrix :: proc($N: int) -> any where N <= 4 {
result: matrix[N, N]int
return result
}
Found some more interesting behavior... This is not legal
field_matrix :: proc($N: int, m: matrix[N, N]int) -> int where N <= 4 {
return N
}
But this IS legal and used in the core library
field_matrix :: proc(m: matrix[$N, N]int) -> int where N <= 4 {
return N
}
I'm currently trying to debug this and I'm not sure how this happens yet as I'm not too familiar with the codebase
I encountered this one just now. It was the second procedure I ever wrote in Odin, in first hour of experimentation. Couldn't figure out what I was doing wrong. My luck :)