Skip to content

alter lookupbykey return type to be optional#22894

Merged
roger-bosman-da merged 11 commits intomainfrom
roger/lookupnbykey-to-optional
Apr 24, 2026
Merged

alter lookupbykey return type to be optional#22894
roger-bosman-da merged 11 commits intomainfrom
roger/lookupnbykey-to-optional

Conversation

@roger-bosman-da
Copy link
Copy Markdown
Contributor

@roger-bosman-da roger-bosman-da commented Apr 15, 2026

In theory, damlc catches calls to lookupbykey with negative (yielding an error) or 0 (yielding the empty list []) n. That being said, to accomodate handwritten LF and to be a bit more precies, we wrap the lookupbykey in an optional, where None indicates failiure (such as a n < 1).

This PR implements the daml side of this change.

  • Change "the staging version" (compiler always just knows of 1) to rc2
  • Change the type of the builtin ULookupNByKey to include an Optional
  • alter lookupNByKey to force the Optional, yielding an error if it is None (it should never be None when compiling with damlc, since n < 1 is already caught by the implementation of lookupNByKey
  • move all lookup functions to Prelude and hide/reexport what needs to be in DA.ContractKeys (this way lookupByKey can use lookupNByKey and does not have to repeat the fromOption`)
  • updated haddoc (fixes NUCK: add stdlib documentation for queryNByKey #22673)

Furthermore, since the change involves a change to the daml-lf json, the golden check was uncommented as well.

Canton companion PR: https://github.com/DACH-NY/canton/pull/32018
GHC companion PR: digital-asset/ghc#193

Steps taken:

  1. [DONE] Daml ad-hoc release that sets type to optional
  2. [DONE] Canton ad-hoc release with DamlScriptIT tests (the only one who use daml) disabled
  3. [DONE] Daml ad-hoc release depending on canton ad-hoc of step 2
  4. [DONE] Merge canton in main depending on daml ad-hoc of step 3
  5. [IN PROGRESS] Merge sdk in main depending on canton snapshot of step 4

@roger-bosman-da roger-bosman-da changed the title lookupnbykey to optional alter lookupbykey return type to be optional Apr 15, 2026
@roger-bosman-da roger-bosman-da added the no-release-notes Apply this label to skip the UNRELEASED.md modification check label Apr 15, 2026
@roger-bosman-da roger-bosman-da force-pushed the roger/lookupnbykey-to-optional branch from f44da35 to 449165c Compare April 16, 2026 08:53
@roger-bosman-da
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@roger-bosman-da roger-bosman-da marked this pull request as ready for review April 16, 2026 15:14
@roger-bosman-da roger-bosman-da force-pushed the roger/lookupnbykey-to-optional branch 3 times, most recently from 0297c1a to 9c78dc7 Compare April 22, 2026 07:31
@roger-bosman-da roger-bosman-da force-pushed the roger/lookupnbykey-to-optional branch from 9c78dc7 to 418ea8d Compare April 22, 2026 07:35
@roger-bosman-da roger-bosman-da force-pushed the roger/lookupnbykey-to-optional branch from 7b04cd2 to 083e477 Compare April 22, 2026 09:03
@roger-bosman-da roger-bosman-da enabled auto-merge (squash) April 24, 2026 08:01
@roger-bosman-da roger-bosman-da force-pushed the roger/lookupnbykey-to-optional branch from 2f035b5 to 3e13fa8 Compare April 24, 2026 08:26
@roger-bosman-da roger-bosman-da merged commit ad26f4b into main Apr 24, 2026
19 checks passed
@roger-bosman-da roger-bosman-da deleted the roger/lookupnbykey-to-optional branch April 24, 2026 10:09
roger-bosman-da added a commit that referenced this pull request Apr 24, 2026
backport of #22894 but with a
3.5.1 canton snapshot inside
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release-notes Apply this label to skip the UNRELEASED.md modification check Standard-Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NUCK: add stdlib documentation for queryNByKey

2 participants