Skip to content

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

@cooldome

Description

@cooldome

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions