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

Running into compile error #1

Closed
arunvickram opened this issue Jan 29, 2021 · 2 comments
Closed

Running into compile error #1

arunvickram opened this issue Jan 29, 2021 · 2 comments

Comments

@arunvickram
Copy link

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:

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?

@oakes
Copy link
Member

oakes commented Jan 29, 2021

Ah yes, you're using 0.13.0, and that bug should be fixed in 0.14.0 :D It's actually a nim bug but 0.14.0 should work around the problem.

@arunvickram
Copy link
Author

Okay that makes sense XD, I updated it to 0.14.0 and it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants