polystat / odin

Object Dependency Inspector
10 stars 2 forks source link

An error in an attempt to find mutual recursion in the chain of inheritance #12

Closed APotyomkin closed 2 years ago

APotyomkin commented 2 years ago

Problematic code

file foo.eo:

+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+alias derived sandbox.derived

[] > foo
  derived > @

file derived.eo:

+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf
+alias base sandbox.base

[] > derived
  base > @
  [self v] > n
    self.m self v > @

file base.eo:

+package sandbox
+alias stdout org.eolang.io.stdout
+alias sprintf org.eolang.txt.sprintf

[] > base
  memory > x
  [self v] > n
    x.write v > @
  [self v] > m
    self.n self v > @

Expected results

Mutual recursion is detected somehow

Actual result

> java -jar polystat-1.0-SNAPSHOT-jar-with-dependencies.jar sandbox temp
No errors
Warning
  XTDE0540: Ambiguous rule match for /objects/o[1]/o[2]/o[1]
Matches both "element(Q{}o)[((empty(attribute::attribute(Q{}base))) and
  (exists(attribute::attribute(Q{}name)))) and
  ((data(parent::element(Q{}o)/attribute::attribute(Q{}line))) = data(@line))]" on line 53 of
and "element(Q{}o)[empty(attribute::attribute(Q{}base))]" on line 42 of
Warning
  XTDE0540: Ambiguous rule match for /objects/o[1]/o[2]/o[2]
Matches both "element(Q{}o)[((empty(attribute::attribute(Q{}base))) and
  (exists(attribute::attribute(Q{}name)))) and
  ((data(parent::element(Q{}o)/attribute::attribute(Q{}line))) = data(@line))]" on line 53 of
and "element(Q{}o)[empty(attribute::attribute(Q{}base))]" on line 42 of
Warning
  XTDE0540: Ambiguous rule match for /objects/o[2]/o[2]/o[1]
Matches both "element(Q{}o)[((empty(attribute::attribute(Q{}base))) and
  (exists(attribute::attribute(Q{}name)))) and
  ((data(parent::element(Q{}o)/attribute::attribute(Q{}line))) = data(@line))]" on line 53 of
and "element(Q{}o)[empty(attribute::attribute(Q{}base))]" on line 42 of
Warning
  XTDE0540: Ambiguous rule match for /objects/o[2]/o[2]/o[2]
Matches both "element(Q{}o)[((empty(attribute::attribute(Q{}base))) and
  (exists(attribute::attribute(Q{}name)))) and
  ((data(parent::element(Q{}o)/attribute::attribute(Q{}line))) = data(@line))]" on line 53 of
and "element(Q{}o)[empty(attribute::attribute(Q{}base))]" on line 42 of
Exception in thread "main" org.polystat.odin.analysis.mutualrec.naive.exceptions$DecorateeNotFound: Object derived tried to decorate base, but the
decoratee object with such name is not defined
on a top level
        at org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$10(TopLevelObjects.scala:71)
        at scala.Option.getOrElse(Option.scala:201)
        at org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$7(TopLevelObjects.scala:71)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$7(TopLevelObjects.scala:68)
        at delay @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.findObjectByName(TopLevelObjects.scala:85)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$6(TopLevelObjects.scala:67)
        at delay @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$3(TopLevelObjects.scala:65)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$2(TopLevelObjects.scala:64)
        at traverse @ org.polystat.odin.analysis.mutualrec.naive.package$.resolveTopLevelObjectsAndAttrs(package.scala:32)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.$anonfun$add$1(TopLevelObjects.scala:60)
        at of @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObject$.$anonfun$createTopLevelObject$2(TopLevelObject.scala:37)
        at map @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObject$.$anonfun$createTopLevelObject$2(TopLevelObject.scala:37)
        at delay @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObject$.createTopLevelObject(TopLevelObject.scala:35)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObject$.createTopLevelObject(TopLevelObject.scala:28)
        at flatMap @ org.polystat.odin.analysis.mutualrec.naive.services.TopLevelObjects$$anon$1.add(TopLevelObjects.scala:59)
        at traverse @ org.polystat.odin.analysis.mutualrec.naive.package$.resolveTopLevelObjectsAndAttrs(package.scala:32)
        at traverse @ org.polystat.odin.analysis.mutualrec.naive.package$.resolveTopLevelObjectsAndAttrs(package.scala:32)
        at traverse @ org.polystat.odin.analysis.mutualrec.naive.package$.resolveTopLevelObjectsAndAttrs(package.scala:32)
        at map @ org.polystat.odin.analysis.mutualrec.naive.package$.resolveTopLevelObjectsAndAttrs(package.scala:32)
fizruk commented 2 years ago

@APotyomkin odin currently only supports analysis of single modules of EO code, so this is expected behaviour.