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

..< wont work for Types #789

Open
juancarlospaco opened this issue Jul 24, 2021 · 4 comments
Open

..< wont work for Types #789

juancarlospaco opened this issue Jul 24, 2021 · 4 comments
Labels
bug Something isn't working compiler_messages errors, warnings, hints compiler

Comments

@juancarlospaco
Copy link
Collaborator

juancarlospaco commented Jul 24, 2021

type 
  X[A: static[int]] = array[0..A,     int]
  Y[B: static[int]] = array[0..B - 1, int]
  Z[C: static[int]] = array[0..<C,    int] 

Fails with not helpful error message, not consistent with rest of the language:

$ nim c example.nim
  Error: cannot generate code for: C

$

Comment out Z type and it works, new people tend to try to use it because is used in the rest of the language,
I do not understand why it wont work because ..< works for in the VM, div and * works but not ..<,
should be fixed and add a test, or if it can not be fixed improve the error message and document why ..< wont work for types,
and how to do it correctly.

@juancarlospaco juancarlospaco added bug Something isn't working compiler_messages errors, warnings, hints compiler labels Jul 24, 2021
@juancarlospaco
Copy link
Collaborator Author

is this valid syntax ?, I can not find any docs.

@timotheecour
Copy link
Owner

timotheecour commented Jul 25, 2021

I'm aware, I know how to fix it (branch pr_fix_6215_array_slice) but it's tricky and caused by fact that compiler hardcodes array type in compiler instead of treating it as a regular type; if it were a regular it'd just work (in fact you can define type array2[N: static int, T] = ...)
also somewhat related to nim-lang#15911

EDIT: duplicate of nim-lang#6215 ?

@juancarlospaco
Copy link
Collaborator Author

So many bugs related, and is labeled as "easy" in that link, is it really easy ?. 🤔

Maybe would be better to documment all the quirks with array explicitly in the manual then...

@timotheecour
Copy link
Owner

and is labeled as "easy"

no that label has been removed a while ago

Maybe would be better to documment all the quirks with array explicitly in the manual then...

it's fixable though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler_messages errors, warnings, hints compiler
Projects
None yet
Development

No branches or pull requests

2 participants