diff --git a/daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/IdString.scala b/daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/IdString.scala index 14482499e61a..b8178cb842a1 100644 --- a/daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/IdString.scala +++ b/daml-lf/data/src/main/scala/com/digitalasset/daml/lf/data/IdString.scala @@ -307,7 +307,7 @@ private[data] final class IdStringImpl extends IdString { */ override type PackageId = String override val PackageId: ConcatenableStringModule[PackageId, HexString] = - new ConcatenableMatchingStringModule("Daml-LF Package ID", "-_ ") + new ConcatenableMatchingStringModule("Daml-LF Package ID", "-_ ", 64) /** Used to reference to leger objects like contractIds, ledgerIds, * transactionId, ... We use the same type for those ids, because we diff --git a/daml-lf/data/src/test/scala/com/digitalasset/daml/lf/data/RefTest.scala b/daml-lf/data/src/test/scala/com/digitalasset/daml/lf/data/RefTest.scala index 81bf2f6b3228..1babd2a49fec 100644 --- a/daml-lf/data/src/test/scala/com/digitalasset/daml/lf/data/RefTest.scala +++ b/daml-lf/data/src/test/scala/com/digitalasset/daml/lf/data/RefTest.scala @@ -204,6 +204,8 @@ class RefTest extends AnyFreeSpec with Matchers with EitherValues { "reject too long string" in { Party.fromString("p" * 255) shouldBe a[Right[_, _]] Party.fromString("p" * 256) shouldBe a[Left[_, _]] + PackageId.fromString("p" * 64) shouldBe a[Right[_, _]] + PackageId.fromString("p" * 65) shouldBe a[Left[_, _]] } } diff --git a/daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/RollbackTest.scala b/daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/RollbackTest.scala index c895268dbaa9..e1a4ea59619a 100644 --- a/daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/RollbackTest.scala +++ b/daml-lf/interpreter/src/test/scala/com/digitalasset/daml/lf/speedy/RollbackTest.scala @@ -30,7 +30,7 @@ class ExceptionTest extends AnyWordSpec with Matchers with TableDrivenPropertyCh implicit val defaultParserParameters: ParserParameters[this.type] = { ParserParameters( - defaultPackageId = Ref.PackageId.assertFromString("-pkgId-"), + defaultPackageId = Ref.PackageId.assertFromString("pkgId"), languageVersion = LanguageVersion.v1_dev, ) } diff --git a/daml-lf/spec/daml-lf-1.rst b/daml-lf/spec/daml-lf-1.rst index 58510681e5a4..10448fe8625d 100644 --- a/daml-lf/spec/daml-lf-1.rst +++ b/daml-lf/spec/daml-lf-1.rst @@ -375,17 +375,10 @@ instances when we want to avoid empty identifiers, escaping problems, and other similar pitfalls. :: PackageId strings - PackageIdString ::= ' PackageIdChars ' -- PackageIdString - - Sequences of PackageId character - PackageIdChars ::= PackageIdChar -- PackageIdChars - | PackageIdChars PackageIdChar - - PackageId character - PackageIdChar ∈ [a-zA-Z0-9\-_ ] -- PackageIdChar + PackageIdString ::= [a-zA-Z0-9\-_ ]{1,64} -- PackageIdString PartyId strings - PartyIdString ∈ [a-zA-Z0-9:\-_ ]{1,255} -- PartyIdChar + PartyIdString ∈ [a-zA-Z0-9:\-_ ]{1,255} -- PartyIdString PackageName strings PackageNameString ∈ [a-zA-Z0-9:\-_]+ -- PackageNameString diff --git a/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala b/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala index 3dbd23f967e9..9fee3ee0d327 100644 --- a/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala +++ b/daml-lf/transaction-test-lib/src/main/scala/lf/value/test/ValueGenerators.scala @@ -77,7 +77,7 @@ object ValueGenerators { // generate a junk identifier val idGen: Gen[Identifier] = for { - n <- Gen.choose(1, 200) + n <- Gen.choose(1, 64) packageId <- Gen .listOfN(n, Gen.alphaNumChar) .map(s => PackageId.assertFromString(s.mkString))