Skip to content

Commit

Permalink
Add "/type" or "/enum" fragment to the error path for "unable to find…
Browse files Browse the repository at this point in the history
… type/enum" errors

This change requires corresponding change in kaitai_struct_tests repository
  • Loading branch information
Mingun committed Mar 8, 2024
1 parent 1e2f0b3 commit d12f272
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ object AttrSpec {
fromYaml2(srcMap, path, metaDef, id)
} catch {
case (epe: Expressions.ParseException) =>
throw KSYParseError.expression(epe, path)
throw KSYParseError.expression(epe, path ++ List("type"))
}
}

def fromYaml2(srcMap: Map[String, Any], path: List[String], metaDef: MetaSpec, id: Identifier): AttrSpec = {
val doc = DocSpec.fromYaml(srcMap, path)
val process = ProcessExpr.fromStr(ParseUtils.getOptValueStr(srcMap, "process", path), path)
val process = ProcessExpr.fromStr(ParseUtils.getOptValueStr(srcMap, "process", path), path ++ List("process"))
// TODO: add proper path propagation
val contents = srcMap.get("contents").map(parseContentSpec(_, path ++ List("contents")))
val size = ParseUtils.getOptValueExpression(srcMap, "size", path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class ResolveTypes(specs: ClassSpecs, topClass: ClassSpec, opaqueTypes: Boolean)
def resolveUserType(curClass: ClassSpec, dataType: DataType, path: List[String]): Iterable[CompilationProblem] = {
dataType match {
case ut: UserType =>
val (resClassSpec, problems) = resolveUserType(curClass, ut.name, path)
val (resClassSpec, problems) = resolveUserType(curClass, ut.name, path ++ List("type"))
ut.classSpec = resClassSpec
problems
case et: EnumType =>
et.enumSpec = resolveEnumSpec(curClass, et.name)
if (et.enumSpec.isEmpty) {
Some(EnumNotFoundErr(et.name, curClass, path))
Some(EnumNotFoundErr(et.name, curClass, path ++ List("enum")))
} else {
None
}
Expand Down

0 comments on commit d12f272

Please sign in to comment.