Skip to content

Commit

Permalink
fix: make imports for other modules than main in packages work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
aboeglin committed May 5, 2024
1 parent 7cac266 commit ac83e20
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions compiler/main/Utils/Path.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import System.FilePath ( dropFileName
, joinPath
, splitFileName
, normalise
, takeExtension, pathSeparator, hasExtension
, takeExtension, pathSeparator, hasExtension, addExtension
)
import qualified MadlibDotJson.MadlibDotJson as MadlibDotJson
import Data.List ( isInfixOf
Expand Down Expand Up @@ -175,9 +175,9 @@ findMadlibPackageMainPath pathUtils file pkgName = do
Right json' -> do
mainPath <- normalisePath pathUtils <$> canonicalizePath pathUtils (joinPath [folder, MadlibDotJson.main json'])
if '/' `elem` pkgName then do
let afterPkg = dropWhile (/= '/') pkgName
let afterPkg = tail $ dropTrailingPathSeparator $ dropWhile (/= '/') pkgName
basePath = takeDirectory mainPath
fullPath = joinPath [basePath, afterPkg, ".mad"]
fullPath = joinPath [basePath, addExtension afterPkg ".mad"]
return $ Just fullPath
else
return $ Just mainPath
Expand Down

0 comments on commit ac83e20

Please # to comment.