Skip to content

Commit

Permalink
Closes #270 bugfix type aliases recompilation (#271)
Browse files Browse the repository at this point in the history
* Moduledoc for the example

* Bugfix recompilation type aliases
  • Loading branch information
wende authored Jan 30, 2018
1 parent 2896ae8 commit 38080b0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
15 changes: 13 additions & 2 deletions elchemy
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
version="0.6.2"
set -e

VERBOSE=false
if [[ $* == *--verbose* ]]; then
VERBOSE=true
fi

function create_file {
local file=$1
if [[ ${file} == *"elm-stuff/packages"* ]]; then
Expand Down Expand Up @@ -68,15 +73,21 @@ case "$1" in
elm-install
fi
# Copy all elixir files that are inside packages
echo "-- Copying Elixir native files --"
for f in `{ find -L elm-stuff/packages -name "*.ex*" | grep -v "\.elchemy\.ex" ;}`
do
echo "FOUND $f"
if [ $VERBOSE = true ]; then
echo "FOUND $f"
fi
file="${file/^elm\//lib\//}"
file=$(create_file $f)
echo "TO $file"
if [ $VERBOSE = true ]; then
echo "TO $file"
fi
cp $f $file
done
i=0
echo "-- Compiling Elm files --"
# Find all elm files inside packages and compile them
for f in `{ find $2 -name "*.elm" -newermt "$MTIME" | grep -v "elm-stuff" | grep -v "#." ; find -L elm-stuff/packages -name "*.elm" -newermt "$MTIME" | grep -v "/tests/" | grep -v "/example/" ;}`
do
Expand Down
3 changes: 2 additions & 1 deletion lib/mix/tasks/compile.elchemy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ defmodule Mix.Tasks.Compile.Elchemy do
end

# Force project to be reloaded and deps compiled after elm-deps created.
IO.puts "Recompiling dependencies for elchemy..."
IO.puts "-- Recompiling dependencies for elchemy --"
if project = Mix.Project.pop() do
%{name: name, file: file} = project
Mix.Project.push(name, file)
end
Mix.Task.run "deps.get"
Mix.Task.run "deps.compile"
IO.puts "-- Elchemy compilation complete --\n"
end
end
16 changes: 1 addition & 15 deletions src/Compiler.elm
Original file line number Diff line number Diff line change
Expand Up @@ -156,25 +156,11 @@ getCommonImports : List ExContext.Commons -> Dict String ExContext.Module
getCommonImports commons =
let
merge aliases acc =
Dict.merge Dict.insert typeAliasDuplicate Dict.insert acc aliases Dict.empty
Dict.merge Dict.insert (\k v v2 -> Dict.insert k v) Dict.insert acc aliases Dict.empty
in
List.foldl (.modules >> merge) Dict.empty commons


typeAliasDuplicate : comparable -> a -> a -> Dict.Dict comparable a -> Dict.Dict comparable a
typeAliasDuplicate k v v2 =
if v /= v2 then
Debug.crash <|
"You can't have two different type aliases for "
++ toString k
++ "\nThese are: "
++ toString v
++ "\nand\n"
++ toString v2
else
Dict.insert k v


getContext : List Statement -> ( Maybe Context, List Statement )
getContext statements =
case statements of
Expand Down

0 comments on commit 38080b0

Please sign in to comment.