Skip to content

Dereferencing a ref type does not compile #11747

@mathysr

Description

@mathysr

Dereferencing a ref type does not compile

No suitable [] implementation is found for the reference type itself. Derefencing an instance works.

Example

type
  MyType = object
    a: int
    b: int
    c: int
  
  MyRefType = ref MyType

echo compiles(MyRefType[])

Remark: the compiles proc checks whether MyRefType[] compiles. As it generates false as output, it does not.

Current Output

false

Expected Output

true

Possible Solution

Additional Information

The issue came up in this thread on the Nim forum when discussing how to get the size of the underying type of a ref.

nim version 0.20.0
https://play.nim-lang.org/#ix=1OE9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions