Skip to content

C compiler error with inline and a proc field in an object  #14758

Open
@ghost

Description

Sorry, couldn't make a better title.

Example

type
  SomePointer = ref | ptr | pointer | proc
  Option[T] = object
    when T is SomePointer:
      val: T
    else:
      val: T
      has: bool

proc some*[T](val: T): Option[T] {.inline.} =
  when T is SomePointer:
    result.val = val
  else:
    result.has = true
    result.val = val

proc none*(T: typedesc): Option[T] {.inline.} =
  discard

type
  Events = object
    # remove this proc and it works
    cb: proc (guild: Option[Guild])
  
  Guild = ref object

proc channelPinsUpdate*() =
  var guild = none Guild
  guild = some Guild()

channelPinsUpdate()

Current Output

/home/dian/.cache/nim/tt_d/@mtt.nim.c: In function ‘some__xq16iLMQ9bb9atkSAOGgyfnQtt’:
/home/dian/.cache/nim/tt_d/@mtt.nim.c:147:11: error: ‘tyObject_Option__tEu09c5iyZ7d63kPxo53T0Q’ has no member named ‘has’
  147 |  (*Result).has = 0;
      | 

Additional information

Regression - works just fine on 1.2.0

$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-06-22
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: 451129de4213805b74b1635565d998904d705458
active boot switches: -d:release -d:danger

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