I've been taking pararules for a spin for a turn based RPG I've been trying to make, but I've run into a particular issue that I haven't been able to diagnose:
Here is the code that triggers the compile error:
type
Battler* = ref object
hp*: int
maxHp*: int
TurnQueue* = HeapQueue[Battler]
Id = enum
Arena,
Attr = enum
CurrentTurn, NextTurn,
CurrentBattler
schema Fact(Id, Attr):
CurrentTurn: TurnQueue
NextTurn: TurnQueue
CurrentBattler: Battler
let rule1 =
rule getCurrentBattler(Fact):
what:
(Arena, CurrentTurn, turn)
then:
var currentTurn = turn
session.insert(Arena, CurrentBattler, currentTurn.pop())
It produces this error:
Verifying dependencies for test_para_nim@0.1.0
Info: Dependency on pararules@any version already satisfied
Verifying dependencies for pararules@0.13.0
Building test_para_nim/test_para_nim using c backend
/Users/arun/Documents/Projects/test_para_nim/src/test_para_nim.nim(28, 8) template/generic instantiation of `rule` from here
/Users/arun/.nimble/pkgs/pararules-0.13.0/pararules.nim(258, 3) template/generic instantiation of `ruleWithAttrs` from here
/Users/arun/Documents/Projects/test_para_nim/src/test_para_nim.nim(33, 14) template/generic instantiation of `insert` from here
/Users/arun/.nimble/pkgs/pararules-0.13.0/pararules.nim(486, 12) template/generic instantiation of `insertFact` from here
/Users/arun/.nimble/pkgs/pararules-0.13.0/pararules/engine.nim(390, 12) template/generic instantiation of `fireRules` from here
/Users/arun/.nimble/pkgs/pararules-0.13.0/pararules/engine.nim(325, 36) Error: type mismatch: got <HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]>
but expected one of:
iterator items(a: cstring): char
first type mismatch at position: 1
required type for a: cstring
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items(a: string): char
first type mismatch at position: 1
required type for a: string
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[IX, T](a: array[IX, T]): T
first type mismatch at position: 1
required type for a: array[IX, T]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T: char](a: openArray[T]): T
first type mismatch at position: 1
required type for a: openArray[T: char]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T: enum](E: typedesc[T]): T
first type mismatch at position: 1
required type for E: type T: enum
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T: not char](a: openArray[T]): lent2 T
first type mismatch at position: 1
required type for a: openArray[T: not char]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T](a: seq[T]): lent2 T
first type mismatch at position: 1
required type for a: seq[T]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T](a: set[T]): T
first type mismatch at position: 1
required type for a: set[T]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
iterator items[T](s: HSlice[T, T]): T
first type mismatch at position: 1
required type for s: HSlice[items.T, items.T]
but expression 'session.thenQueue[]' is of type: HashSet[tuple[node: ptr MemoryNode[test_para_nim.Fact, Vars[test_para_nim.Fact]], idAttrs: IdAttrs]]
expression: items(session.thenQueue[])
Tip: 4 messages have been suppressed, use --verbose to show them.
Error: Build failed for package: test_para_nim
... Execution failed with exit code 256
... Command: /Users/arun/.nimble/bin/nim c --colors:on --noNimblePath -d:NimblePkgVersion=0.1.0 --path:/Users/arun/.nimble/pkgs/pararules-0.13.0 --hints:off -o:/Users/arun/Documents/Projects/test_para_nim/test_para_nim /Users/arun/Documents/Projects/test_para_nim/src/test_para_nim.nim
I checked to see why it's throwing an error, and it seems like it's being de-referenced properly. Do you have any ideas as to why this might be the case?
Hey @oakes,
I've been taking pararules for a spin for a turn based RPG I've been trying to make, but I've run into a particular issue that I haven't been able to diagnose:
Here is the code that triggers the compile error:
It produces this error:
I checked to see why it's throwing an error, and it seems like it's being de-referenced properly. Do you have any ideas as to why this might be the case?