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

lent codegen error for c++ (works with c,js,vm) #15958

Closed
timotheecour opened this issue Nov 13, 2020 · 0 comments · Fixed by #15970
Closed

lent codegen error for c++ (works with c,js,vm) #15958

timotheecour opened this issue Nov 13, 2020 · 0 comments · Fixed by #15970

Comments

@timotheecour
Copy link
Member

timotheecour commented Nov 13, 2020

lent codegen error for c++ (works with c,js,vm)

Example

when true: # D20201113T132829
  proc byLent[T](a: T): lent T = a
  let a = [11,12]
  doAssert byLent(a) == [11,12] # error: no matching function for call 

Current Output

@mt11278.nim.cpp:160:48: error: no matching function for call to 'byLent__YR8W5QF853QkzHxY0HJTiA'
                NIM_BOOL T3_ = eqeq___kPWPhCv4sxSS5oUvoHpOvQ(byLent__YR8W5QF853QkzHxY0HJTiA(a__9aK0EFj6IzQ9aQ33j9bVJ0VvA), TM__tQ8kc6yAWJgOgIMsVcTMMQ_2);
                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/timothee/git_clone/nim/timn/build/nimcache/@mt11278.nim.cpp:107:30: note: candidate function not viable: no known conversion from 'tyArray__HU7qaqKu9czJLT84iCBJnsA' (aka 'NI [2]') to 'tyArray__HU7qaqKu9czJLT84iCBJnsA *'
      (aka 'NI (*)[2]') for 1st argument; take the address of the argument with &
N_LIB_PRIVATE N_NIMCALL(NI*, byLent__YR8W5QF853QkzHxY0HJTiA)(tyArray__HU7qaqKu9czJLT84iCBJnsA* a) {
                             ^
/Users/timothee/git_clone/nim/Nim_devel/lib/nimbase.h:252:44: note: expanded from macro 'N_NIMCALL'
#  define N_NIMCALL(rettype, name) rettype name /* no modifier */

Expected Output

works

Additional Information

  • devel 1.5.1 c39fa0d
  • works with c, js, vm

eg:

when true:
  template main=
    proc byLent[T](a: T): lent T = a
    let a = [11,12]
    doAssert byLent(a) == [11,12]
  static: main() # ok
  main() # bug
  • works with tuple instead of array:
when true:
  proc byLent[T](a: T): lent T = a
  let a2 = (11,)
  doAssert byLent(a2) == (11,)
cooldome added a commit that referenced this issue Nov 14, 2020
@cooldome cooldome mentioned this issue Nov 14, 2020
Araq pushed a commit that referenced this issue Nov 20, 2020
* fix #15958

* also cover openArray and VarArgs

* more tests

* cover even more types

* cover even more types

* Trigger build

* Trigger build

* cover sets passed as arrays
narimiran pushed a commit that referenced this issue Nov 20, 2020
* fix #15958

* also cover openArray and VarArgs

* more tests

* cover even more types

* cover even more types

* Trigger build

* Trigger build

* cover sets passed as arrays

(cherry picked from commit fcb2ec4)
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
* fix nim-lang#15958

* also cover openArray and VarArgs

* more tests

* cover even more types

* cover even more types

* Trigger build

* Trigger build

* cover sets passed as arrays
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
* fix nim-lang#15958

* also cover openArray and VarArgs

* more tests

* cover even more types

* cover even more types

* Trigger build

* Trigger build

* cover sets passed as arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant