diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala index 6a2755c0a7f8..a2fe272a8aad 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/Error.scala @@ -91,11 +91,9 @@ object Error { } private[engine] object MissingPackage { - def apply(pkgId: Ref.PackageId): Lookup = - Lookup(language.LookupError.Package(pkgId)) def unapply(error: Lookup): Option[Ref.PackageId] = error.lookupError match { - case language.LookupError.Package(packageId) => Some(packageId) + case language.LookupError(language.Reference.Package(packageId), _) => Some(packageId) case _ => None } } diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala index 0f30072733b5..b9cb510e19d2 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/ValueEnricher.scala @@ -33,7 +33,7 @@ final class ValueEnricher(engine: Engine) { private[this] def handleLookup[X](lookup: => Either[LookupError, X]) = lookup match { case Right(value) => ResultDone(value) - case Left(LookupError.Package(pkgId)) => + case Left(LookupError.MissingPackage(pkgId)) => engine .loadPackages(List(pkgId)) .flatMap(_ => diff --git a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/preprocessing/Preprocessor.scala b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/preprocessing/Preprocessor.scala index 6e14553f9de6..d064a0daf022 100644 --- a/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/preprocessing/Preprocessor.scala +++ b/daml-lf/engine/src/main/scala/com/digitalasset/daml/lf/engine/preprocessing/Preprocessor.scala @@ -81,7 +81,7 @@ private[engine] final class Preprocessor(compiledPackages: MutableCompiledPackag tyConAlreadySeen0 + tyCon, tmplsAlreadySeen0, ) - case Left(LookupError.Package(pkgId)) => + case Left(LookupError.MissingPackage(pkgId)) => pullPackage(pkgId) case Left(e) => ResultError(Error.Preprocessing.Lookup(e)) @@ -107,7 +107,7 @@ private[engine] final class Preprocessor(compiledPackages: MutableCompiledPackag if (tyConAlreadySeen0(tmplId)) typs0 else Ast.TTyCon(tmplId) :: typs0 val typs2 = template.key.fold(typs1)(_.typ :: typs1) go(typs2, tmplsToProcess, tyConAlreadySeen0, tmplsAlreadySeen0) - case Left(LookupError.Package(pkgId)) => + case Left(LookupError.MissingPackage(pkgId)) => pullPackage(pkgId) case Left(error) => ResultError(Error.Preprocessing.Lookup(error)) diff --git a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala index 2fcafb374cde..291aecdb6baf 100644 --- a/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala +++ b/daml-lf/engine/src/test/scala/com/digitalasset/daml/lf/engine/EngineTest.scala @@ -314,8 +314,9 @@ class EngineTest val res = preprocessor .preprocessCommands(ImmArray(command)) .consume(lookupContract, lookupPackage, lookupKey) - inside(res) { case Left(Error.Preprocessing(Error.Preprocessing.Lookup(error))) => - error shouldBe a[language.LookupError.TemplateKey] + inside(res) { + case Left(Error.Preprocessing(Error.Preprocessing.Lookup(language.LookupError(ref, _)))) => + ref shouldBe a[language.Reference.TemplateKey] } } diff --git a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala index ac5bfbbd1e1c..f9680563b00b 100644 --- a/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala +++ b/daml-lf/interpreter/src/main/scala/com/digitalasset/daml/lf/speedy/Compiler.scala @@ -355,7 +355,7 @@ private[lf] final class Compiler( case Compiler.NoPackageValidation => case Compiler.FullPackageValidation => Validation.checkPackage(interface, pkgId, pkg).left.foreach { - case EUnknownDefinition(_, LookupError.Package(pkgId_)) => + case EUnknownDefinition(_, LookupError.MissingPackage(pkgId_)) => logger.trace(s"compilePackage: Missing $pkgId_, requesting it...") throw PackageNotFound(pkgId_) case e => diff --git a/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala b/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala index 2fbedb2d94d6..4092f5edc5d8 100644 --- a/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala +++ b/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/Interface.scala @@ -11,123 +11,225 @@ private[lf] class Interface(signatures: PartialFunction[PackageId, PackageSignat import Interface._ + private[this] def lookupPackage( + pkgId: PackageId, + context: => Reference, + ): Either[LookupError, PackageSignature] = + signatures.lift(pkgId).toRight(LookupError(Reference.Package(pkgId), context)) + def lookupPackage(pkgId: PackageId): Either[LookupError, PackageSignature] = - signatures.lift(pkgId).toRight(LookupError.Package(pkgId)) + lookupPackage(pkgId, Reference.Package(pkgId)) - def lookupModule( + private[this] def lookupModule( pkgId: PackageId, modName: ModuleName, + context: => Reference, ): Either[LookupError, ModuleSignature] = - lookupPackage(pkgId).flatMap(_.modules.get(modName).toRight(LookupError.Module(pkgId, modName))) + lookupPackage(pkgId, context).flatMap( + _.modules.get(modName).toRight(LookupError(Reference.Module(pkgId, modName), context)) + ) - def lookupDefinition(name: TypeConName): Either[LookupError, DefinitionSignature] = - lookupModule(name.packageId, name.qualifiedName.module).flatMap( - _.definitions.get(name.qualifiedName.name).toRight(LookupError.Definition(name)) + def lookupModule(pkgId: PackageId, modName: ModuleName): Either[LookupError, ModuleSignature] = + lookupModule(pkgId, modName, Reference.Module(pkgId, modName)) + + private[this] def lookupDefinition( + name: TypeConName, + context: => Reference, + ): Either[LookupError, DefinitionSignature] = + lookupModule(name.packageId, name.qualifiedName.module, context).flatMap( + _.definitions + .get(name.qualifiedName.name) + .toRight(LookupError(Reference.Definition(name), context)) ) + def lookupDefinition(name: TypeConName): Either[LookupError, DefinitionSignature] = + lookupDefinition(name, Reference.Definition(name)) + // Throws a Definition LookupError, if name does not maps to a Definition. // Throws a TypeSyn LookupError, if name map to a Definition which is not a DTypeSyn. - def lookupTypeSyn(name: TypeSynName): Either[LookupError, DTypeSyn] = - lookupDefinition(name).flatMap { + private[this] def lookupTypeSyn( + name: TypeSynName, + context: => Reference, + ): Either[LookupError, DTypeSyn] = + lookupDefinition(name, context).flatMap { case typeSyn: DTypeSyn => Right(typeSyn) - case _ => Left(LookupError.TypeSyn(name)) + case _ => Left(LookupError(Reference.TypeSyn(name), context)) } + def lookupTypeSyn(name: TypeSynName): Either[LookupError, DTypeSyn] = + lookupTypeSyn(name, Reference.TypeSyn(name)) + // Throws a Definition LookupError, if name does not maps to a Definition. // Throws a TypeSyn LookupError, if name map to a Definition which is not a DDataType. - def lookupDataType(name: TypeConName): Either[LookupError, DDataType] = - lookupDefinition(name).flatMap { + private[this] def lookupDataType( + name: TypeConName, + context: => Reference, + ): Either[LookupError, DDataType] = + lookupDefinition(name, context).flatMap { case dataType: DDataType => Right(dataType) - case _ => Left(LookupError.DataType(name)) + case _ => Left(LookupError(Reference.DataType(name), context)) } - def lookupDataRecord( - tyCon: TypeConName + def lookupDataType(name: TypeConName): Either[LookupError, DDataType] = + lookupDataType(name, Reference.DataType(name)) + + private[this] def lookupDataRecord( + tyCon: TypeConName, + context: => Reference, ): Either[LookupError, DataRecordInfo] = - lookupDataType(tyCon).flatMap { dataType => + lookupDataType(tyCon, context).flatMap { dataType => dataType.cons match { case record: DataRecord => Right(DataRecordInfo(dataType, record)) - case _ => Left(LookupError.DataRecord(tyCon)) + case _ => Left(LookupError(Reference.DataRecord(tyCon), context)) } } - def lookupRecordFieldInfo( + def lookupDataRecord(tyCon: TypeConName): Either[LookupError, DataRecordInfo] = + lookupDataRecord(tyCon, Reference.DataRecord(tyCon)) + + private[this] def lookupRecordFieldInfo( tyCon: TypeConName, fieldName: FieldName, + context: => Reference, ): Either[LookupError, RecordFieldInfo] = - lookupDataRecord(tyCon).flatMap { recordDataInfo => + lookupDataRecord(tyCon, context).flatMap { recordDataInfo => recordDataInfo.dataRecord.fieldInfo.get(fieldName) match { case Some((typ, index)) => Right(RecordFieldInfo(recordDataInfo, typ, index)) - case None => Left(LookupError.DataRecordField(tyCon, fieldName)) + case None => Left(LookupError(Reference.DataRecordField(tyCon, fieldName), context)) } } - def lookupDataVariant( - tyCon: TypeConName + def lookupRecordFieldInfo( + tyCon: TypeConName, + fieldName: FieldName, + ): Either[LookupError, RecordFieldInfo] = + lookupRecordFieldInfo(tyCon, fieldName, Reference.DataRecordField(tyCon, fieldName)) + + private[this] def lookupDataVariant( + tyCon: TypeConName, + context: => Reference, ): Either[LookupError, DataVariantInfo] = - lookupDataType(tyCon).flatMap(dataType => + lookupDataType(tyCon, context).flatMap(dataType => dataType.cons match { case cons: DataVariant => Right(DataVariantInfo(dataType, cons)) - case _ => Left(LookupError.DataVariant(tyCon)) + case _ => Left(LookupError(Reference.DataVariant(tyCon), context)) } ) - def lookupVariantConstructor( + def lookupDataVariant(tyCon: TypeConName): Either[LookupError, DataVariantInfo] = + lookupDataVariant(tyCon, Reference.DataVariant(tyCon)) + + private[this] def lookupVariantConstructor( tyCon: TypeConName, consName: VariantConName, + context: => Reference, ): Either[LookupError, VariantConstructorInfo] = - lookupDataVariant(tyCon).flatMap(variantInfo => + lookupDataVariant(tyCon, context).flatMap(variantInfo => variantInfo.dataVariant.constructorInfo.get(consName) match { case Some((typ, rank)) => Right(VariantConstructorInfo(variantInfo, typ, rank)) - case None => Left(LookupError.DataVariantConstructor(tyCon, consName)) + case None => Left(LookupError(Reference.DataVariantConstructor(tyCon, consName), context)) } ) - def lookupDataEnum( - tyCon: TypeConName + def lookupVariantConstructor( + tyCon: TypeConName, + consName: VariantConName, + ): Either[LookupError, VariantConstructorInfo] = + lookupVariantConstructor(tyCon, consName, Reference.DataVariantConstructor(tyCon, consName)) + + private[this] def lookupDataEnum( + tyCon: TypeConName, + context: => Reference, ): Either[LookupError, DataEnumInfo] = - lookupDataType(tyCon).flatMap { dataType => + lookupDataType(tyCon, context).flatMap { dataType => dataType.cons match { case cons: DataEnum => Right(DataEnumInfo(dataType, cons)) - case _ => Left(LookupError.DataEnum(tyCon)) + case _ => Left(LookupError(Reference.DataEnum(tyCon), context)) } } - def lookupEnumConstructor(tyCon: TypeConName, consName: EnumConName): Either[LookupError, Int] = - lookupDataEnum(tyCon).flatMap { dataEnumInfo => + def lookupDataEnum(tyCon: TypeConName): Either[LookupError, DataEnumInfo] = + lookupDataEnum(tyCon, Reference.DataEnum(tyCon)) + + private[this] def lookupEnumConstructor( + tyCon: TypeConName, + consName: EnumConName, + context: => Reference, + ): Either[LookupError, Int] = + lookupDataEnum(tyCon, context).flatMap { dataEnumInfo => dataEnumInfo.dataEnum.constructorRank.get(consName) match { case Some(rank) => Right(rank) - case None => Left(LookupError.DataVariantConstructor(tyCon, consName)) + case None => Left(LookupError(Reference.DataVariantConstructor(tyCon, consName), context)) } } + def lookupEnumConstructor(tyCon: TypeConName, consName: EnumConName): Either[LookupError, Int] = + lookupEnumConstructor(tyCon, consName, Reference.DataEnumConstructor(tyCon, consName)) + + private[this] def lookupTemplate( + name: TypeConName, + context: => Reference, + ): Either[LookupError, TemplateSignature] = + lookupModule(name.packageId, name.qualifiedName.module, context).flatMap( + _.templates + .get(name.qualifiedName.name) + .toRight(LookupError(Reference.Template(name), context)) + ) + def lookupTemplate(name: TypeConName): Either[LookupError, TemplateSignature] = - lookupModule(name.packageId, name.qualifiedName.module).flatMap( - _.templates.get(name.qualifiedName.name).toRight(LookupError.Template(name)) + lookupTemplate(name, Reference.Template(name)) + + private[this] def lookupChoice( + tmpName: TypeConName, + chName: ChoiceName, + context: => Reference, + ): Either[LookupError, TemplateChoiceSignature] = + lookupTemplate(tmpName, context).flatMap( + _.choices.get(chName).toRight(LookupError(Reference.Choice(tmpName, chName), context)) ) def lookupChoice( tmpName: TypeConName, chName: ChoiceName, ): Either[LookupError, TemplateChoiceSignature] = - lookupTemplate(tmpName).flatMap( - _.choices.get(chName).toRight(LookupError.Choice(tmpName, chName)) + lookupChoice(tmpName, chName, Reference.Choice(tmpName, chName)) + + private[this] def lookupTemplateKey( + name: TypeConName, + context: => Reference, + ): Either[LookupError, TemplateKeySignature] = + lookupTemplate(name, context).flatMap( + _.key.toRight(LookupError(Reference.TemplateKey(name), context)) ) def lookupTemplateKey(name: TypeConName): Either[LookupError, TemplateKeySignature] = - lookupTemplate(name).flatMap(_.key.toRight(LookupError.TemplateKey(name))) + lookupTemplateKey(name, Reference.TemplateKey(name)) - def lookupValue(name: ValueRef): Either[LookupError, DValueSignature] = - lookupDefinition(name).flatMap { + private[this] def lookupValue( + name: ValueRef, + context: => Reference, + ): Either[LookupError, DValueSignature] = + lookupDefinition(name, context).flatMap { case valueDef: DValueSignature => Right(valueDef) - case _ => Left(LookupError.Value(name)) + case _ => Left(LookupError(Reference.Value(name), context)) } - def lookupException(name: TypeConName): Either[LookupError, DefExceptionSignature] = - lookupModule(name.packageId, name.qualifiedName.module).flatMap( - _.exceptions.get(name.qualifiedName.name).toRight(LookupError.Exception(name)) + def lookupValue(name: ValueRef): Either[LookupError, DValueSignature] = + lookupValue(name, Reference.Value(name)) + + private[this] def lookupException( + name: TypeConName, + context: => Reference, + ): Either[LookupError, DefExceptionSignature] = + lookupModule(name.packageId, name.qualifiedName.module, context).flatMap( + _.exceptions + .get(name.qualifiedName.name) + .toRight(LookupError(Reference.Exception(name), context)) ) + def lookupException(name: TypeConName): Either[LookupError, DefExceptionSignature] = + lookupException(name, Reference.Exception(name)) + val packageLanguageVersion: PartialFunction[PackageId, LanguageVersion] = signatures andThen (_.languageVersion) diff --git a/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala b/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala index 2d213cab2720..af9dc52ef673 100644 --- a/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala +++ b/daml-lf/language/src/main/scala/com/digitalasset/daml/lf/language/LookupError.scala @@ -3,79 +3,97 @@ package com.daml.lf.language +import com.daml.lf.data.Ref import com.daml.lf.data.Ref._ -sealed abstract class LookupError extends Product with Serializable { - def pretty: String +final case class LookupError(notFound: Reference, context: Reference) { + val pretty: String = "unknown " + notFound.pretty + ( + if (context == notFound) "" else " while looking for " + context.pretty + ) } object LookupError { + object MissingPackage { + def unapply(err: LookupError): Option[PackageId] = + err.notFound match { + case Reference.Package(packageId) => Some(packageId) + case _ => None + } + } +} + +sealed abstract class Reference extends Product with Serializable { + def pretty: String +} + +object Reference { - final case class Package(packageId: PackageId) extends LookupError { - def pretty: String = s"unknown package $packageId." + final case class Package(packageId: PackageId) extends Reference { + override def pretty: String = s"package $packageId." } - final case class Module(packageId: PackageId, moduleRef: ModuleName) extends LookupError { - def pretty: String = s"unknown module $packageId:$moduleRef" + final case class Module(packageId: PackageId, moduleName: ModuleName) extends Reference { + override def pretty: String = s"module $packageId:$moduleName" } - final case class Definition(conName: TypeConName) extends LookupError { - def pretty: String = s"unknown definition $conName" + final case class Definition(identifier: Ref.Identifier) extends Reference { + override def pretty: String = s"definition $identifier" } - final case class TypeSyn(syn: TypeSynName) extends LookupError { - def pretty: String = s"unknown type synonym $syn" + final case class TypeSyn(tyCon: TypeConName) extends Reference { + override def pretty: String = s"type synonym $tyCon" } - final case class DataType(conName: TypeConName) extends LookupError { - def pretty: String = s"unknown data type $conName" + final case class DataType(tyCon: TypeConName) extends Reference { + override def pretty: String = s"data type $tyCon" } - final case class DataRecord(tyCon: TypeConName) extends LookupError { - def pretty: String = s"unknown record $tyCon" + final case class DataRecord(tyCon: TypeConName) extends Reference { + override def pretty: String = s"record $tyCon" } - final case class DataRecordField(tyCon: TypeConName, conName: Ast.VariantConName) - extends LookupError { - def pretty: String = s"unknown record field $conName in record $tyCon" + final case class DataRecordField(tyCon: TypeConName, fieldName: Ast.FieldName) extends Reference { + override def pretty: String = s"record field $fieldName in record $tyCon" } - final case class DataVariant(tyCon: TypeConName) extends LookupError { - def pretty: String = s"unknown variant $tyCon" + final case class DataVariant(tyCon: TypeConName) extends Reference { + override def pretty: String = s"variant $tyCon" } - final case class DataVariantConstructor(tyCon: TypeConName, conName: Ast.VariantConName) - extends LookupError { - def pretty: String = s"unknown constructor $conName in variant $tyCon" + final case class DataVariantConstructor( + tyCon: TypeConName, + constructorName: Ast.VariantConName, + ) extends Reference { + override def pretty: String = s"constructor $constructorName in variant $tyCon" } - final case class DataEnum(tyCon: TypeConName) extends LookupError { - def pretty: String = s"unknown enumeration $tyCon" + final case class DataEnum(tyCon: TypeConName) extends Reference { + override def pretty: String = s"enumeration $tyCon" } - final case class DataEnumConstructor(tyCon: TypeConName, conName: Ast.EnumConName) - extends LookupError { - def pretty: String = s"unknown constructor $conName in enumeration $tyCon" + final case class DataEnumConstructor(tyCon: TypeConName, constructorName: Ast.EnumConName) + extends Reference { + override def pretty: String = s"constructor $constructorName in enumeration $tyCon" } - final case class Value(valName: ValueRef) extends LookupError { - def pretty: String = s"unknown value $valName" + final case class Value(identifier: Ref.Identifier) extends Reference { + override def pretty: String = s"value $identifier" } - final case class Template(conName: TypeConName) extends LookupError { - def pretty: String = s"unknown template $conName" + final case class Template(tyCon: TypeConName) extends Reference { + override def pretty: String = s"template $tyCon" } - final case class TemplateKey(conName: TypeConName) extends LookupError { - def pretty: String = s"template without contract key $conName." + final case class TemplateKey(tyCon: TypeConName) extends Reference { + override def pretty: String = s"template without contract key $tyCon." } - final case class Choice(conName: TypeConName, choiceName: ChoiceName) extends LookupError { - def pretty: String = s"unknown choice $choiceName in template $conName" + final case class Choice(tyCon: TypeConName, choiceName: ChoiceName) extends Reference { + override def pretty: String = s"choice $choiceName in template $tyCon" } - final case class Exception(conName: TypeConName) extends LookupError { - def pretty: String = s"unknown exception: ${conName.qualifiedName}" + final case class Exception(tyCon: TypeConName) extends Reference { + override def pretty: String = s"exception: $tyCon" } } diff --git a/daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala b/daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala index 3d9597779f38..8df666c0ee61 100644 --- a/daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala +++ b/daml-lf/validation/src/test/scala/com/digitalasset/daml/lf/validation/TypingSpec.scala @@ -5,7 +5,7 @@ package com.daml.lf.validation import com.daml.lf.data.Ref.DottedName import com.daml.lf.language.Ast._ -import com.daml.lf.language.{LookupError, Interface, LanguageVersion => LV} +import com.daml.lf.language.{Interface, LookupError, Reference, LanguageVersion => LV} import com.daml.lf.testing.parser.Implicits._ import com.daml.lf.testing.parser.{defaultLanguageVersion, defaultPackageId} import com.daml.lf.validation.SpecUtil._ @@ -455,9 +455,10 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher { case _: EEmptyConsFront => }, //ExpVal E"⸨ Mod:g ⸩" -> // - { case EUnknownDefinition(_, LookupError.Definition(_)) => }, + { case EUnknownDefinition(_, LookupError(Reference.Definition(_), Reference.Value(_))) => + }, E"⸨ Mod:R ⸩" -> // - { case EUnknownDefinition(_, LookupError.Value(_)) => }, + { case EUnknownDefinition(_, LookupError(Reference.Value(_), Reference.Value(_))) => }, //ExpRecCon E"Λ (σ : ⋆). λ (e₁ : Bool) (e₂ : List σ) → ⸨ Mod:R @σ { f1 = e₁, f2 = e₂ } ⸩" -> // { case _: ETypeMismatch => }, @@ -470,9 +471,15 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher E"Λ (σ : ⋆) (τ: ⋆). λ (e₁ : Int64) (e₂ : List σ) (e₃:τ) → ⸨ Mod:R @σ { f1 = e₁, f2 = e₂, f3 = e₃} ⸩" -> // { case _: EFieldMismatch => }, E"Λ (σ : ⋆). λ (e₁ : Bool) (e₂ : List σ) → ⸨ Mod:g @σ { f1 = e₁, f2 = e₂ } ⸩" -> // - { case EUnknownDefinition(_, LookupError.Definition(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Definition(_), Reference.DataType(_)), + ) => + }, E"Λ (σ : ⋆). λ (e₁ : Bool) (e₂ : List σ) → ⸨ Mod:S @σ { f1 = e₁, f2 = e₂ } ⸩" -> // - { case EUnknownDefinition(_, LookupError.DataType(_)) => }, + { case EUnknownDefinition(_, LookupError(Reference.DataType(_), Reference.DataType(_))) => + }, // ExpRecProj E"Λ (σ : ⋆ → ⋆). ⸨ Mod:R @σ {f2} nothing⸩" -> // { case _: EKindMismatch => }, @@ -501,9 +508,15 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher E"Λ (τ : ⋆) (σ : ⋆). λ (e : σ) → ⸨ Mod:Tree:Leaf @τ e ⸩" -> // { case _: ETypeMismatch => }, E"Λ (τ : ⋆) (σ : ⋆). λ (e : σ) → ⸨ Mod:g:Leaf @τ e ⸩" -> // - { case EUnknownDefinition(_, LookupError.Definition(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Definition(_), Reference.DataType(_)), + ) => + }, E"Λ (τ : ⋆) (σ : ⋆). λ (e : σ) → ⸨ Mod:S:Leaf @τ e ⸩" -> // - { case EUnknownDefinition(_, LookupError.DataType(_)) => }, + { case EUnknownDefinition(_, LookupError(Reference.DataType(_), Reference.DataType(_))) => + }, // ExpStructCon E"Λ (τ₁: ⋆) (τ₂: ⋆). λ (e₁: τ₁) (e₂: τ₂) → ⸨ ⟨ f₁ = e₁, f₁ = e₂ ⟩ ⸩" -> // { case _: EDuplicateField => }, @@ -595,7 +608,12 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher { case _: EExpectedAnyType => }, // ExpToAnyException E"λ (r: Mod:T) → ⸨ to_any_exception @(Mod:T) r ⸩" -> // - { case EUnknownDefinition(_, LookupError.Exception(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Exception(_), Reference.Exception(_)), + ) => + }, E"λ (t: Bool) → ⸨ to_any_exception @Bool t ⸩" -> // { case _: EExpectedExceptionType => }, E"Λ (τ :⋆). λ (t: ∀ (α : ⋆). Int64) → ⸨ to_any_exception @(∀ (α : ⋆). Int64) t ⸩" -> // @@ -606,7 +624,12 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher { case _: ETypeMismatch => }, // ExpFromAnyException E"λ (t: AnyException) → ⸨ from_any_exception @Mod:T t ⸩" -> // - { case EUnknownDefinition(_, LookupError.Exception(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Exception(_), Reference.Exception(_)), + ) => + }, E"λ (t: Any) → ⸨ from_any_exception @Bool t ⸩" -> // { case _: EExpectedExceptionType => }, E"λ (t: ∀ (α : ⋆). Int64) → ⸨ from_any_exception @(∀ (α : ⋆). Int64) t ⸩" -> // @@ -617,9 +640,19 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher E"⸨ throw @Mod:R @Mod:E nothing ⸩" -> // { case _: EKindMismatch => }, E"Λ (τ :⋆). λ (e : Mod:U) → ⸨ throw @τ @Mod:U e ⸩" -> // - { case EUnknownDefinition(_, LookupError.Exception(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Exception(_), Reference.Exception(_)), + ) => + }, E"Λ (τ :⋆). λ (e : Mod:U) → ⸨ throw @τ @Mod:U e ⸩" -> // - { case EUnknownDefinition(_, LookupError.Exception(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Exception(_), Reference.Exception(_)), + ) => + }, E"Λ (τ :⋆). λ (e : Bool) → ⸨ throw @τ @Bool e ⸩" -> // { case _: EExpectedExceptionType => }, E"Λ (τ :⋆). λ (e: ∀ (α : ⋆). Int64) → ⸨ throw @τ @(∀ (α : ⋆). Int64) e ⸩" -> // @@ -697,14 +730,25 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher { case _: ETypeMismatch => }, // UpdCreate E"λ (e: Mod:U) → ⸨ create @Mod:U nothing ⸩" -> // - { case EUnknownDefinition(_, LookupError.Template(_)) => }, + { case EUnknownDefinition(_, LookupError(Reference.Template(_), Reference.Template(_))) => + }, E"Λ (σ : ⋆). λ (e: σ) → ⸨ create @Mod:T e ⸩" -> // { case _: ETypeMismatch => }, // UpdExercise E"λ (e₂: List Party) (e₃: Int64) → ⸨ exercise @Mod:U Ch nothing e₂ e₃ ⸩" -> // - { case EUnknownDefinition(_, LookupError.Template(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Template(_), Reference.Choice(_, _)), + ) => + }, E"λ (e₁: ContractId Mod:T) (e₂: List Party) (e₃: Int64) → ⸨ exercise @Mod:T Not e₁ e₂ e₃ ⸩" -> // - { case EUnknownDefinition(_, LookupError.Choice(_, _)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Choice(_, _), Reference.Choice(_, _)), + ) => + }, E"Λ (σ : ⋆).λ (e₁: ContractId Mod:T) (e₂: List Party) (e₃: σ) → ⸨ exercise @Mod:T Ch e₁ e₂ e₃ ⸩" -> // { case _: ETypeMismatch => }, E"Λ (σ : ⋆).λ (e₁: ContractId Mod:T) (e₂: List σ) (e₃: Int64) → ⸨ exercise @Mod:T Ch e₁ e₂ e₃ ⸩" -> // @@ -715,14 +759,24 @@ class TypingSpec extends AnyWordSpec with TableDrivenPropertyChecks with Matcher { case _: ETypeMismatch => }, // FecthByKey & lookupByKey E"""⸨ fetch_by_key @Mod:U "Bob" ⸩""" -> // - { case EUnknownDefinition(_, LookupError.Template(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Template(_), Reference.TemplateKey(_)), + ) => + }, E"""⸨ fetch_by_key @Mod:T "Bob" ⸩""" -> // { case _: ETypeMismatch => }, E"""⸨ lookup_by_key @Mod:T "Bob" ⸩""" -> // { case _: ETypeMismatch => }, // UpdFetch E"Λ (σ: ⋆). λ (e: ContractId Mod:U) → ⸨ fetch @Mod:U e ⸩" -> // - { case EUnknownDefinition(_, LookupError.Template(_)) => }, + { + case EUnknownDefinition( + _, + LookupError(Reference.Template(_), Reference.Template(_)), + ) => + }, E"Λ (σ : ⋆). λ (e: σ) → ⸨ fetch @Mod:T e ⸩" -> // { case _: ETypeMismatch => }, // ScenarioEmbedExpr diff --git a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala index 98597f2603bb..efd48ae42743 100644 --- a/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala +++ b/ledger/participant-integration-api/src/test/suite/scala/platform/apiserver/services/ApiSubmissionServiceSpec.scala @@ -31,7 +31,7 @@ import com.daml.lf.data.Time.Timestamp import com.daml.lf.data.{ImmArray, Ref} import com.daml.lf.engine.{Error => LfError} import com.daml.lf.interpretation.{Error => LfInterpretationError} -import com.daml.lf.language.LookupError +import com.daml.lf.language.{LookupError, Reference} import com.daml.lf.transaction.test.TransactionBuilder import com.daml.lf.transaction.{GlobalKey, NodeId, ReplayNodeMismatch} import com.daml.lf.value.Value @@ -268,7 +268,10 @@ class ApiSubmissionServiceSpec ErrorCause.DamlLf( LfError.Preprocessing( LfError.Preprocessing.Lookup( - LookupError.Package(Ref.PackageId.assertFromString("-pkgId")) + LookupError( + Reference.Package(Ref.PackageId.assertFromString("-pkgId")), + Reference.Package(Ref.PackageId.assertFromString("-pkgId")), + ) ) ) ) -> Status.INVALID_ARGUMENT,