Skip to content

Commit

Permalink
Fix location of scoped modulePathName (#3011)
Browse files Browse the repository at this point in the history
Closes #2737.

This issues caused the formatter to sometimes insert unwanted line
breaks.
  • Loading branch information
janmasrovira committed Sep 9, 2024
1 parent 7167cb3 commit d891908
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ checkImportNoPublic ::
checkImportNoPublic import_@Import {..} = do
massert (_importPublic == NoPublic)
smodule <- readScopeModule import_
let sname :: S.TopModulePath = smodule ^. scopedModulePath
let sname :: S.TopModulePath = set nameConcrete _importModulePath (smodule ^. scopedModulePath)
sname' :: S.Name = set S.nameConcrete (topModulePathToName _importModulePath) sname
scopedModule :: ScopedModule = set scopedModuleName sname' smodule
exportInfoOriginal = scopedModule ^. scopedModuleExportInfo
Expand All @@ -638,7 +638,8 @@ checkImportNoPublic import_@Import {..} = do
_importAsName = qual',
_importOpen = importOpen',
_importUsingHiding = usingHiding',
..
_importKw,
_importPublic
}
where
addModuleToScope :: ScopedModule -> Sem r ()
Expand Down
4 changes: 4 additions & 0 deletions test/Scope/Positive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,5 +265,9 @@ tests =
posTest
"Scan name with 'import' prefix"
$(mkRelDir "issue2929")
$(mkRelFile "main.juvix"),
posTest
"Proper formatting of import module path"
$(mkRelDir "issue2737")
$(mkRelFile "main.juvix")
]
9 changes: 9 additions & 0 deletions tests/positive/issue2737/M.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- 1
-- 2
-- 3
-- 4
-- 5
-- 6
-- 7
-- 8
module M;
8 changes: 8 additions & 0 deletions tests/positive/issue2737/Package.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module Package;

import PackageDescription.V2 open;

package : Package :=
defaultPackage@?{
name := "issue2737"
};
5 changes: 5 additions & 0 deletions tests/positive/issue2737/main.juvix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module main;

import M as N;

-- comment at the end

0 comments on commit d891908

Please sign in to comment.