Skip to content

Commit b4c39d6

Browse files
committed
fix: struct conversion
1 parent d574cfc commit b4c39d6

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/main/scala/io/github/kelvindev15/prolog/core/Struct.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Struct:
2424

2525
private case class StructImpl(functor: Atom, arguments: Term*) extends Struct:
2626
override val arity: Int = arguments.size
27-
override def asTerm: Term = this
27+
override def asTerm: Term = Struct(functor, arguments map { _.asTerm }*)
2828

2929
trait Indicator extends Struct:
3030
val functor: Atom = Functors.INDICATOR

src/test/scala/io/github/kelvindev15/prolog/core/TestTermConversion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TestTermConversion extends AnyFunSuite with Matchers:
2121

2222
test("A directive is a unary struct with :- as a functor"):
2323
Directive(Struct(Atom("dynamic"), Indicator(Atom("foo"), Constant.Numeric(2)))).asTerm shouldBe
24-
Struct(Atom(":-"), Struct(Atom("/"), Atom("foo"), Constant.Numeric(2)))
24+
Struct(Atom(":-"), Struct(Atom("dynamic"), Struct(Atom("/"), Atom("foo"), Constant.Numeric(2))))
2525

2626
test("A conjunction of goals is a binary recursive struct with , as a functor"):
2727
val functor = Atom(",")

0 commit comments

Comments
 (0)