timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

misc error msg #104

Open timotheecour opened 4 years ago

timotheecour commented 4 years ago

links

timotheecour commented 4 years ago
when defined case2: # D20200419T033153
  var a = 10
  var b: uint = 12
  for i in a..b:
    echo $($type(i), i)

=> looks like some weird transfo was applied, and no clear reference to

  template dotdotImpl(t) {.dirty.} =
    iterator `..`*(a, b: t): t {.inline.} =
t10581.nim(37, 13) Error: type mismatch: got <HSlice[system.int, system.uint]>
but expected one of:
iterator items(E: typedesc[enum]): E:type
  first type mismatch at position: 1
  required type for E: type enum
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items(a: cstring): char
  first type mismatch at position: 1
  required type for a: cstring
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items(a: string): char
  first type mismatch at position: 1
  required type for a: string
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items[IX, T](a: array[IX, T]): T
  first type mismatch at position: 1
  required type for a: array[IX, T]
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items[T](a: openArray[T]): T
  first type mismatch at position: 1
  required type for a: openArray[T]
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items[T](a: seq[T]): T
  first type mismatch at position: 1
  required type for a: seq[T]
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items[T](a: set[T]): T
  first type mismatch at position: 1
  required type for a: set[T]
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]
iterator items[T](s: HSlice[T, T]): T
  first type mismatch at position: 1
  required type for s: HSlice[items.T, items.T]
  but expression 'a .. b' is of type: HSlice[system.int, system.uint]

expression: items(a .. b)
    for i in a..b:
timotheecour commented 4 years ago
timotheecour commented 4 years ago
timotheecour commented 4 years ago

-[ ] and has to be used (or discarded); start of expression here: points to wrong location

D20200506T223706

nim r $timn_D/tests/nim/all/t10700.nim /Users/timothee/git_clone/nim/timn/tests/nim/all/t10700.nim(9, 1) template/generic instantiation from here /Users/timothee/git_clone/nim/timn/tests/nim/all/t10700.nim(12, 6) Error: expression 'ret2`gensym36362015' is of type 'int' and has to be used (or discarded); start of expression here: /Users/timothee/git_clone/nim/timn/tests/nim/all/t10700.nim(10, 3) to2("12", int) ^

template to2*[S](a: S, T: typed): untyped =
  var ret2: T
  ret2

proc main()=
  var ret: int
  ret = 1
  to2("12", int)
main()
timotheecour commented 3 years ago

refs https://github.com/nim-lang/Nim/issues/16001#issuecomment-730118098 refs TITLE: nim check (or --errormax:N) reports redundant errors · Issue #16178 · nim-lang/Nim

timotheecour commented 3 years ago

I've just read the elm blog and I'm very impressed - clear and explicit. The json output they have could be really useful for IDEs as well.

timotheecour commented 3 years ago
timotheecour commented 3 years ago

refs: https://github.com/nim-lang/Nim/pull/16152#issuecomment-742189649

timotheecour commented 3 years ago
t10570.nim(12, 6) Error: type mismatch: got <pointer>
but expected one of:
proc fun(a: P): string
  first type mismatch at position: 1
  required type for a: P
  but expression '' is of type: pointer

expression: fun()
  proc fun(a: P): string {.borrow.}

at very least, '' and fun() are wrong