Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error for ambiguous BUILTIN [FROMNAT no longer working] #4520

Closed
dylanede opened this issue Mar 17, 2020 · 3 comments
Closed

Better error for ambiguous BUILTIN [FROMNAT no longer working] #4520

dylanede opened this issue Mar 17, 2020 · 3 comments
Assignees
Labels
builtin Enhancements to the builtin modules and builtin definitions type: enhancement Issues and pull requests about possible improvements ux: error reporting Issues to do with how Agda reports errors
Milestone

Comments

@dylanede
Copy link
Contributor

I have returned to an older piece of Agda code that looks like the following:

{-# OPTIONS --cubical #-}

module scratch where

open import Cubical.Data.Nat
open import Agda.Primitive

private
  variable
    ℓ ℓ' : Level

record FromNat (A : Set ℓ) : Set (lsuc ℓ) where
  field
    Constraint : SetfromNat : (n : ℕ) ⦃ _ : Constraint n ⦄  A
open FromNat ⦃ ... ⦄ public using (fromNat)

{-# BUILTIN FROMNAT fromNat #-}

Here, I now get the following error on master:

The argument to BUILTIN FROMNAT must be a defined unambiguous name
when scope checking the declaration
  {-# BUILTIN FROMNAT fromNat #-}

Am I missing something obvious?

@andreasabel andreasabel added cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp builtin Enhancements to the builtin modules and builtin definitions ux: error reporting Issues to do with how Agda reports errors labels Mar 17, 2020
@andreasabel
Copy link
Member

andreasabel commented Mar 17, 2020

Importing Cubical.Data.Nat already imports the BUILTIN FROMNAT via the following builtin module. Also Cubical.Data.Nat exports fromNat, thus you are creating an ambiguous name by the open statement.

module Agda.Builtin.FromNat where

open import Agda.Primitive
open import Agda.Builtin.Nat

record Number {a} (A : Set a) : Set (lsuc a) where
  field
    Constraint : Nat  Set a
    fromNat :  n  {{_ : Constraint n}}  A

open Number {{...}} public using (fromNat)

{-# BUILTIN FROMNAT fromNat #-}
{-# DISPLAY Number.fromNat _ n = fromNat n #-}

The error message is misleading, though.

@dylanede
Copy link
Contributor Author

Ah gotcha. Should this issue stay open with the aim of improving the error message then?

@andreasabel andreasabel self-assigned this Mar 17, 2020
@andreasabel andreasabel added type: enhancement Issues and pull requests about possible improvements and removed cubical Cubical Agda paraphernalia: Paths, Glue, partial elements, hcomp, transp labels Mar 17, 2020
@andreasabel andreasabel added this to the 2.6.2 milestone Mar 17, 2020
@andreasabel
Copy link
Member

New error is:

Name  fromNat  is ambiguous
when scope checking the declaration
  {-# BUILTIN FROMNAT fromNat #-}

@andreasabel andreasabel changed the title BUILTIN FROMNAT no longer working Better error for ambiguous BUILTIN [FROMNAT no longer working] Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtin Enhancements to the builtin modules and builtin definitions type: enhancement Issues and pull requests about possible improvements ux: error reporting Issues to do with how Agda reports errors
Projects
None yet
Development

No branches or pull requests

2 participants