Agda: Confusing error when inserting declaration before top-level module

Created on 16 Oct 2017  路  3Comments  路  Source: agda/agda

Consider this valid Agda program:

module Issue2808 where
record Issue2808 : Set where

Now, if I accidentially put a declaration before the top level module header,

postulate A : Set
module Issue2808 where
record Issue2808 : Set where

I get this confusing error:

Duplicate definition of module Issue2808. Previous definition of
module Issue2808 at ...
when scope checking the declaration
  record Issue2808 where

The problem is that then Agda interprets the input as

module _ where
postulate A : Set
module Issue2808 where
record Issue2808 : Set where

I come to the conviction that allowing to omit the top-level module header completely was a mistake...

Related: #1077

error-reporting modules syntax bug

All 3 comments

I think we should row back a bit and require at least a module _ where top-level header.

I suppose big developments would not be affected, as there anyway modules have sensible names.

I have previously suggested that one should only be allowed to omit the name for top-level modules, not for imported modules.

Since @UlfNorell had reservations about the rowing back, I fixed this in the minimal way by widening the fix for #1077 to the following situation:


-- module _ where  -- If this is added, we get the error about duplicate module

postulate A : Set  -- Accepted if this is deleted

module Issue2808 where

record Issue2808 : Set where

-- Expected error: (at the postulate)
-- Illegal declaration(s) before top-level module
Was this page helpful?
0 / 5 - 0 ratings

Related issues

GavinMendelGleason picture GavinMendelGleason  路  4Comments

mietek picture mietek  路  4Comments

nad picture nad  路  3Comments

GoogleCodeExporter picture GoogleCodeExporter  路  4Comments

GoogleCodeExporter picture GoogleCodeExporter  路  4Comments