Skip to content
CCPEDIAby Unity Nodes
App Development

"Used tuple of size > 5!"... but where?

3 posts362 viewsLast activity Jan 2023

  1. WallaceKellyOP

    If you daml build the daml-finance-app, you get the following warning:

    File:     src/daml/Daml/Finance/Setup/Scenario/OtcSwaps.daml
    Hidden:   no
    Range:    24:1-24:4
    Source:   Core to Daml-LF
    Severity: DsWarning
    Message:  Used tuple of size > 5! Daml only has Show, Eq, Ord instances for tuples of size <= 5.
    

    I understand the issue and the fact that the Show type class is only defined for up to five-element tuples.

    What I cannot figure out is why does OtcSwaps.daml trigger this warning?

    I see tuples…

    • of size two ("Public", singleton public), ("USD", cashRoute), etc…
    • of size three (ty, tm, td)

    …but nothing of size > 5.

  2. Gary_Verhaegen

    Hi @WallaceKelly,

    You’ll have to wait for a compiler engineer to confirm, but my suspicion is that line 28:

        all@[operator, public, centralBank, seller, buyer] = map (.id) parties
    

    generates a large tuple as part of its desugaring, and the warning is based on the desugared code representation rather than the actual code.

    This is supported by the fact that breaking down that line into (with an appropriate import DA.List ((!!), head)):

        all = map (.id) parties
        operator = head all
        public = all !! 1
        centralBank = all !! 2
        seller = all !! 3
        buyer = all !! 4
    

    gets rid of the warning, at least for me.

  3. cocreature

    This is a bug. It has already been fixed in 2.5.0. For some reason the finance app was still stuck on an older snapshot. Upgraded in Upgrade to 2.5.0 by cocreature · Pull Request #82 · digital-asset/daml-finance-app · GitHub