-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Zokka-Dev/fix-occurs-check-bug
Fix occurs check bug
- Loading branch information
Showing
10 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"type": "application", | ||
"source-directories": [ | ||
"src" | ||
], | ||
"elm-version": "0.19.1", | ||
"dependencies": { | ||
"direct": { | ||
"elm/browser": "1.0.2", | ||
"elm/core": "1.0.5", | ||
"elm/html": "1.0.0" | ||
}, | ||
"indirect": { | ||
"elm/json": "1.1.3", | ||
"elm/time": "1.0.0", | ||
"elm/url": "1.0.0", | ||
"elm/virtual-dom": "1.0.3" | ||
} | ||
}, | ||
"test-dependencies": { | ||
"direct": {}, | ||
"indirect": {} | ||
}, | ||
"zokka-package-overrides": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module BadOccursCheck exposing (..) | ||
|
||
-- https://github.com/elm/compiler/issues/2241 | ||
|
||
foldMap : (a -> b) -> (a -> c) -> (b -> c -> c) -> a -> c | ||
foldMap fab fac fbc a = fac a | ||
|
||
f : a -> a -> a | ||
f x y = x | ||
|
||
break : Float -> (Float, Float) | ||
break input = foldMap identity (\x -> (x, x)) (\( low, high ) x -> ( f low x, f high x )) input |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
module BadOccursCheck1 exposing (..) | ||
-- From an error that showed up on incremental-elm Slack | ||
|
||
-- This file will cause the vanilla Elm compiler to hang when compiling. | ||
|
||
type Effect msg = Effect | ||
|
||
type Msg = Msg1 Int | Msg2 Int | ||
|
||
-- All our functions will be infinite loops since this is only meant to test | ||
-- type checking and we don't care about any runtime stuff | ||
-- We won't use Debug.todo just in case we want to double-check that all of | ||
-- this works fine when we run `--optimize` (although presently I can't | ||
-- think of any reason why --optimize would change anything WRT | ||
-- typechecking, but just in case!) | ||
applyIf : Bool -> (a -> a) -> a -> a | ||
applyIf x = applyIf x | ||
|
||
update : model -> ( model, Effect msg ) | ||
update x = update x | ||
|
||
withQuery : (data -> msg) -> Effect msg -> ( model, Effect msg ) -> ( model, Effect msg ) | ||
withQuery f = withQuery f | ||
|
||
-- A nice hack to get us values without resorting to Debug.todo | ||
-- Can't just directly do x = x because the Elm compiler detects that | ||
makeAnything : a -> b | ||
makeAnything x = makeAnything x | ||
|
||
query1 = makeAnything () | ||
|
||
query2 = makeAnything () | ||
|
||
model = makeAnything () | ||
|
||
result condition = | ||
model | ||
|> update | ||
|> applyIf condition withQuery Msg1 query1 | ||
|> applyIf condition withQuery Msg1 query2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import subprocess | ||
import os | ||
import timeit | ||
|
||
def run_zokka_make(zokka_cmd, file_to_make, project_dir): | ||
return subprocess.run([zokka_cmd, "make", file_to_make], cwd=project_dir) | ||
|
||
if __name__ == "__main__": | ||
|
||
start_time = timeit.default_timer() | ||
|
||
find_zokka_cmd = ["cabal", "list-bin", "zokka"] | ||
|
||
|
||
zokka_exec_location = \ | ||
subprocess.run(find_zokka_cmd, capture_output=True).stdout.strip() | ||
|
||
run_zokka_make_cmd = [zokka_exec_location, ] | ||
|
||
current_dir = "." | ||
|
||
top_level_tests_dir = os.path.join(current_dir, "compiler-output-tests") | ||
|
||
print(f"=========\nRunning compiler-output tests found in {top_level_tests_dir}\n=========\n") | ||
|
||
bad_occurs_check_test_0 =\ | ||
run_zokka_make(zokka_exec_location, os.path.join("src", "BadOccursCheck.elm"), top_level_tests_dir) | ||
|
||
if bad_occurs_check_test_0.returncode == 0: | ||
raise Exception("Our bad occurs check failed! The compiler succeeded when it should have failed!") | ||
|
||
bad_occurs_check_test_1 =\ | ||
run_zokka_make(zokka_exec_location, os.path.join("src", "BadOccursCheck1.elm"), top_level_tests_dir) | ||
|
||
if bad_occurs_check_test_1.returncode == 0: | ||
raise Exception("Our bad occurs check failed! The compiler succeeded when it should have failed!") | ||
|
||
total_test_duration = timeit.default_timer() - start_time | ||
|
||
print(f"=========\nTotal test duration: {total_test_duration} seconds\n=========\n") |