Skip to content

Spurious "Unknown Constructor" errors when misusing Pair constructor #1187

@KtorZ

Description

@KtorZ

What Git revision are you using?

What operating system are you using, and which version?

  • Linux / Ubuntu
  • Linux / Other
  • macOS
  • Windows

Describe what the problem is?

I noted at least two problems when using the Pair constructor. In both cases, the type-checker fails (rightfully in the second case) with a wrong and confusing error message.

  1. When using the constructor as a partial function:

    fuzz.map2(Pair, cardano.credential(), fuzz.int_at_least(1))

    Here, map2 first argument should be fn(a, b) -> Pair(a, b), which in principle Pair satisfies. But instead of providing a relevant error, the compiler fails pointing at an unknown constructor Pair.

  2. If we misuse Pair passing only one argument; for example:

    Pair(Credential.Script(permissions_validator_hash, 0))

    The compiler fails again with an unknown constructor error about Pair; confusing.

What should be the expected behavior?

In the first scenario, we the use of Pair as a function should simply be allowed, like it is for all other constructors.
In the second scenario, the compiler should instead raise an incorrect arity error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Status

    🪣 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions