Skip to content

Spurious error when using iterator with static parameter. #25

Closed
@beef331

Description

@beef331

When using an iterator that uses a static parameter for the return type as following the DSL causes an error:

import owlkettle

type
  Thing = enum
    a, b, c
  MyType[T: static Thing] = object

iterator doThing(val: static Thing): MyType[val] = yield MyType[val]()

viewable App:
  a: int

method view(app: AppState): Widget =
  result = gui:
    Window:
      title = "Counter"
      defaultSize = (200, 60)
      Box():
        for val in doThing(a):
          Label(text = "hello")

brew(gui(App()))

/home/jason/.nimble/pkgs/owlkettle-#head/owlkettle/guidsl.nim(189, 23) Error: A nested proc can have generic parameters only when it is used as an operand to another routine and the types of the generic paramers can be inferred from the expected signature.

This might be resolved in closure generation by wrapping with when ident isnot static: var ident = ident. Or if the code is typed checking if the symKind is a var/let instead of just using all syms.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions