Skip to content

Commit

Permalink
Handle symtab case for path resolution
Browse files Browse the repository at this point in the history
If the multiple results from the symbol table only
differ by the path to the same definition then
there is no ambiguity. This can happen because of
implicit definitions (includes).

Also, if a non-implicit unnamed entry in the symbol
table occurs, make sure it generates an error

Also, add a new Arbitrary local test for the
kalix-improving-template project.
  • Loading branch information
reid-spencer committed Nov 18, 2023
1 parent 3c8aa4c commit e1315a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.reactific.riddl.language.AST.{Entity, *}
import com.reactific.riddl.language.{CommonOptions, Messages}
import com.reactific.riddl.passes.{Pass, PassInfo, PassInput, PassOutput, PassesOutput}
import com.reactific.riddl.passes.symbols.{SymbolsOutput, SymbolsPass}
import com.reactific.riddl.utils.SeqHelpers.SeqHelpers

import scala.collection.mutable
import scala.reflect.{ClassTag, classTag}
Expand Down Expand Up @@ -276,6 +275,9 @@ case class ResolutionPass(input: PassInput, outputs: PassesOutput) extends Pass(
case (d, _) :: Nil =>
wrongType[T](pathId, parent, d)
Seq.empty
case (d, pars) :: tail if tail.map(_._1).forall(x => x == d && isSameKind[T](x)) =>
resolved[T](pathId, parent, d)
d +: pars
case list =>
ambiguous[T](pathId, list)
Seq.empty
Expand Down Expand Up @@ -351,7 +353,7 @@ case class ResolutionPass(input: PassInput, outputs: PassesOutput) extends Pass(
findAnchorInParents(topName, parents) match
case afip: AnchorFoundInParents => afip
case _: AnchorNotFoundInParents =>
// Its not an ancestor so le'ts try the symbol table
// Its not an ancestor so let's try the symbol table
findAnchorInSymTab(topName) match
case afis: AnchorFoundInSymTab => afis
case anfis: AnchorNotFoundInSymTab => anfis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ case class SymbolsPass(input: PassInput, outputs: PassesOutput) extends Pass(inp
val included: Seq[SymTabItem] = existing :+ (definition -> copy)
symTab.update(name, included)
parentage.update(definition, copy)
} else {
messages.addError(definition.loc, "Non implicit value with empty name should not happen")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class RunRiddlcOnArbitraryTest extends RunCommandSpecBase {
val fullPath = Path.of(cwd, config)
info(s"config path is: ${fullPath.toAbsolutePath.toString}")
if Files.isReadable(fullPath) then {
val args = Seq("--show-times", "from", fullPath.toString, "validate")
val args = Seq("--show-times", "--verbose", "from", fullPath.toString, "validate")
runWith(args)
} else {
info(s"Skipping unreadable $fullPath")
Expand All @@ -47,6 +47,11 @@ class RunRiddlcOnArbitraryTest extends RunCommandSpecBase {
val config = "design/src/main/riddl/OffTheTop.conf"
validateLocalProject(cwd, config)
}
"validate kalix template" in {
val cwd = "/Users/reid/Code/Improving/kalix-improving-template"
val config = "design/src/main/riddl/ksoapp.conf"
validateLocalProject(cwd, config)
}
// FIXME: Fix Improving.app syntax and renable
// "validate Improving.app" in {
// val cwd = "/Users/reid/Code/improving.app/riddl"
Expand Down

0 comments on commit e1315a8

Please sign in to comment.