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

It is not possible to specify a pragma for the proc that returns `lent T` #9633

Closed
cooldome opened this issue Nov 6, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@cooldome
Copy link
Member

commented Nov 6, 2018

This example compiles

type
  MyField = object
    b: seq[string]

  MyObject = object
    f: MyField

proc getX(x: MyObject): lent MyField = 
  x.f

let a = MyObject()
echo a.getX.b.len

This one doesn't compile (the only difference is pragma):

type
  MyField = object
    b: seq[string]

  MyObject = object
    f: MyField

proc getX(x: MyObject): lent MyField {.inline.} = 
  x.f

let a = MyObject()
echo a.getX.b.len

Compilation fails with error: Error: type expected

@GULPF

This comment has been minimized.

Copy link
Member

commented Nov 6, 2018

This works:

type
  MyField = object
    b: seq[string]

  MyObject = object
    f: MyField

proc getX(x: MyObject): lent(MyField) {.inline.} =
  x.f

let a = MyObject()
echo a.getX.b.len

I guess this happens because lent isn't implemented as a keyword.

@krux02

This comment has been minimized.

Copy link
Contributor

commented Nov 6, 2018

as glupf has pointed out, it is possible.

@krux02 krux02 closed this Nov 6, 2018

@Araq

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

Meh, still a parser quirk that I need to look into.

@Araq Araq reopened this Nov 7, 2018

@Araq Araq added the Parser label Nov 7, 2018

@Araq Araq closed this in 05683e3 Nov 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.