[ fix ] respect visibility in forward data declarations

This commit is contained in:
Guillaume Allais 2023-02-08 17:38:29 +00:00 committed by G. Allais
parent b173267f50
commit f76c4c4307
5 changed files with 21 additions and 5 deletions

View File

@ -467,17 +467,18 @@ processData {vars} eopts nest env fc vis mbtot (MkImpData dfc n_in mty_raw opts
-- When looking up, note the data types which were undefined at the
-- point of declaration.
ndefm <- lookupCtxtExact n (gamma defs)
(mw, fullty) <- the (Core (List Name, ClosedTerm)) $ case ndefm of
(mw, vis, fullty) <- the (Core (List Name, Visibility, ClosedTerm)) $ case ndefm of
Nothing => case mfullty of
Nothing => throw (GenericMsg fc "Missing telescope for data definition \{show n_in}")
Just fullty => pure ([], fullty)
Just fullty => pure ([], vis, fullty)
Just ndef =>
let vis = max (visibility ndef) vis in
case definition ndef of
TCon _ _ _ _ _ mw [] _ => case mfullty of
Nothing => pure (mw, type ndef)
Nothing => pure (mw, vis, type ndef)
Just fullty =>
do ok <- convert defs [] fullty (type ndef)
if ok then pure (mw, fullty)
if ok then pure (mw, vis, fullty)
else do logTermNF "declare.data" 1 "Previous" [] (type ndef)
logTermNF "declare.data" 1 "Now" [] fullty
throw (AlreadyDefined fc n)

View File

@ -269,7 +269,7 @@ idrisTests = MkTestPool "Misc" [] Nothing
-- Implicit laziness, lazy evaluation
"lazy001", "lazy002",
-- Namespace blocks
"namespace001", "namespace002", "namespace003",
"namespace001", "namespace002", "namespace003", "namespace004",
-- Parameters blocks
"params001", "params002", "params003",
-- Larger programs arising from real usage. Typically things with

View File

@ -0,0 +1,11 @@
namespace Core
public export
data D : Type
data D : Type where
MkD : D
d : D
d = MkD

View File

@ -0,0 +1 @@
1/1: Building Export (Export.idr)

View File

@ -0,0 +1,3 @@
rm -rf build
$1 --no-color --console-width 0 --check Export.idr