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

[ARC] Type-bound assign op is not being generated #15510

Closed
ghost opened this issue Oct 7, 2020 · 1 comment
Closed

[ARC] Type-bound assign op is not being generated #15510

ghost opened this issue Oct 7, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 7, 2020

This fails to compile while it shouldn't. Found in https://github.com/paranim/pararules

Example

type
  MemoryNode = ref object

proc main() =
  var node: ptr MemoryNode
  var data: seq[(MemoryNode, string)]
  data.add((node: node[], text: "hello"))

main()

Current Output

/home/dian/Projects/stuff/a.nim(7, 23) Error: internal error: '=' operator not found for type MemoryNode

Expected Output

No compilation error, but of course it'll crash at runtime because it's dereferencing a null pointer.

$ nim -v
Nim Compiler Version 1.3.7 [Linux: amd64]
Compiled at 2020-10-07
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: acbe27b082c202895df1b78a82951389b4a232a0
active boot switches: -d:release -d:danger
@ghost
Copy link
Author

ghost commented Oct 7, 2020

Full version of the original proc:

proc fireRules*[T](session: var Session[T]) =
  # find all nodes with `then` blocks that need executed
  var thenNodes: seq[ptr MemoryNode[T]]
  for node in session.thenNodes[].items:
    thenNodes.add(node)
  if thenNodes.len == 0:
    return
  session.thenNodes[].clear
  # collect all nodes/vars to be executed
  var thenQueue: seq[(MemoryNode[T], Vars[T])]
  for node in thenNodes:
    node.trigger = false
    for match in node.matches.values:
      if match.enabled:
        thenQueue.add((node: node[], vars: match.vars)) # compiler fails on this line
  # execute `then` blocks
  for (node, vars) in thenQueue:
    node.callback(vars)
  # recur because there may be new `then` blocks to execute
  session.fireRules()

Araq added a commit that referenced this issue Oct 8, 2020
@Araq Araq closed this as completed in cfba237 Oct 8, 2020
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants