vilterp/datalog-ts

core: constructing a record in head can give different results in calling rule vs when it's bound as one var

Opened this issue · 0 comments

Calling rule:

hl.Segment{type: T, id: I, span: S, highlight: H} :-
  hl.segmentInt{type: T, id: I, span: S, highlight: H} |
  hl.segmentString{type: T, id: I, span: S, highlight: H} |
  hl.segmentBool{type: T, id: I, span: S, highlight: H} |
  hl.keyword{type: T, id: I, span: S, highlight: H} |
  hl.segmentIdent{type: T, id: I, span: S, highlight: H} |
  hl.segmentSpecialVar{type: T, id: I, span: S, highlight: H} |
  hl.segmentIdentDefnHL{type: T, id: I, span: S, highlight: H} |
  hl.segmentIdentUsageHL{type: T, id: I, span: S, highlight: H} |
  hl.segmentComment{type: T, id: I, span: S, highlight: H}.

Works:

hl.segmentIdentDefnHL{type: "defn", span: S, highlight: true} :-
  ide.CurrentDefnOrDefnOfCurrentVar{span: S}.

Doesn't work:
inlining ide.CurrentDefnOrDefnOfCurrentVar:

hl.segmentIdentDefnHL{type: "defn", span: span{from: F, to: T}, highlight: true} :-
  scope.Defn{span: span{from: F, to: T}} &
  ide.Cursor{idx: CIdx} &
  F <= CIdx & CIdx <= T.

These should work the same. Something's going wrong with bindings in the simple interpreter.