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

$type(myarray.high) shows range 0..3(int) instead of int #13796

Open
timotheecour opened this issue Mar 29, 2020 · 1 comment
Open

$type(myarray.high) shows range 0..3(int) instead of int #13796

timotheecour opened this issue Mar 29, 2020 · 1 comment

Comments

@timotheecour
Copy link
Member

timotheecour commented Mar 29, 2020

$type(myarray.high) shows range 0..3(int) instead of int

Example

when true:
  var a: array[0..3, float]
  const N = high(a)
  doAssert N is int
  echo $type(N)

Current Output

range 0..3(int)

Expected Output

int

Example 2

this leads to misleading error messages, eg:

when true:
  proc bar(a: csize_t) = discard
  proc fun[R](a: array[R, char]) =
    const N = high(a)
    bar(N)
  var a: array[0..512, char]
  fun(a)
 Error: type mismatch: got <range 0..512(int)>
but expected one of:
proc bar(a: csize_t)
  first type mismatch at position: 1
  required type for a: csize_t
  but expression 'N' is of type: range 0..512(int)

expression: bar(N)
      bar(N)

Additional Information

  • 0a49fe5 1.1.1
  • looks like this never worked
@timotheecour timotheecour changed the title $type(myarray.high) shows range 0..3(int) instead of int $type(myarray.high) shows range 0..3(int) instead of int Mar 29, 2020
@metagn
Copy link
Collaborator

metagn commented Nov 3, 2024

this leads to misleading error messages, eg:

Don't really see how that's misleading, it still mentions that it's int.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants