1
1
mirror of https://github.com/anoma/juvix.git synced 2024-10-26 17:52:17 +03:00

Typcheck imports before statements (#2253)

- closes #2248
This commit is contained in:
Jan Mas Rovira 2023-07-11 12:26:52 +02:00 committed by GitHub
parent 366afb5dad
commit 9fdf848e3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 6 deletions

View File

@ -48,11 +48,16 @@ checkModuleNoCache ::
Sem r Module
checkModuleNoCache (ModuleIndex Module {..}) = do
_moduleBody' <-
(evalState (mempty :: NegativeTypeParameters) . checkModuleBody) _moduleBody
evalState (mempty :: NegativeTypeParameters)
. checkModuleBody
$ _moduleBody
_moduleExamples <- mapM checkExample _moduleExamples
return
Module
{ _moduleBody = _moduleBody',
..
_moduleName,
_moduleExamples,
_modulePragmas
}
checkModuleBody ::
@ -60,8 +65,8 @@ checkModuleBody ::
ModuleBody ->
Sem r ModuleBody
checkModuleBody ModuleBody {..} = do
_moduleStatements' <- mapM checkStatement _moduleStatements
_moduleImports' <- mapM checkImport _moduleImports
_moduleStatements' <- mapM checkStatement _moduleStatements
return
ModuleBody
{ _moduleStatements = _moduleStatements',

View File

@ -422,7 +422,7 @@ addIdens idens = do
functionDefEval :: forall r'. Member (State FunctionsTable) r' => FunctionDef -> Sem r' (Maybe Expression)
functionDefEval = runFail . goTop
where
goTop :: forall r. (Members '[Fail, State FunctionsTable] r) => FunctionDef -> Sem r Expression
goTop :: forall r. Members '[Fail, State FunctionsTable] r => FunctionDef -> Sem r Expression
goTop f =
case f ^. funDefClauses of
c :| [] -> goClause c
@ -458,7 +458,7 @@ functionDefEval = runFail . goTop
go :: [(PatternArg, Expression)] -> Sem r Expression
go = \case
[] -> return (c ^. clauseBody)
((p, ty) : ps)
(p, ty) : ps
| Implicit <- p ^. patternArgIsImplicit -> fail
| otherwise -> go ps >>= goPattern (p ^. patternArgPattern, ty)

View File

@ -236,7 +236,11 @@ tests =
posTest
"Nested pattern match with type variables"
$(mkRelDir ".")
$(mkRelFile "NestedPatterns.juvix")
$(mkRelFile "NestedPatterns.juvix"),
posTest
"issue2248: Import type alias"
$(mkRelDir "issue2248")
$(mkRelFile "Main.juvix")
]
<> [ compilationTest t | t <- Compilation.tests
]

View File

@ -0,0 +1,8 @@
module Bug;
type A := mkA : A;
aliasA : Type;
aliasA := A;
type C := mkC : aliasA -> C;

View File

@ -0,0 +1,5 @@
module Main;
import Bug open;
c : C := mkC mkA;

View File

@ -0,0 +1,4 @@
dependencies:
- .juvix-build/stdlib/
name: issue2248
version: 0.0.0