Skip to content

matrix type cannot be used in parapoly #3009

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

Open
edyu opened this issue Dec 7, 2023 · 3 comments
Open

matrix type cannot be used in parapoly #3009

edyu opened this issue Dec 7, 2023 · 3 comments
Labels

Comments

@edyu
Copy link
Contributor

edyu commented Dec 7, 2023

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 report output:
        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.

  1. Use matrix in parapoly function declaration
  2. Compile
  3. Won't compile

Failure Logs

Please include any relevant log snippets or files here.

@xtactis
Copy link
Contributor

xtactis commented Dec 7, 2023

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
}

@xtactis
Copy link
Contributor

xtactis commented Dec 7, 2023

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

@theb1rd
Copy link

theb1rd commented Mar 2, 2024

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 :)

@github-actions github-actions bot added the stale label Jun 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants