From ca395b5c097afd0bd5f78923907bcf459692a631 Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Thu, 10 Sep 2020 14:02:19 -0700 Subject: [PATCH] Add programs to trigger error cases. --- code/compiler/13/examples/errors/double_catchall.txt | 6 ++++++ code/compiler/13/examples/errors/duplicate_type_param.txt | 1 + code/compiler/13/examples/errors/exhausted_patterns.txt | 7 +++++++ code/compiler/13/examples/errors/incomplete_patterns.txt | 5 +++++ .../compiler/13/examples/errors/invalid_case_analysis.txt | 7 +++++++ code/compiler/13/examples/errors/match_after_catchall.txt | 7 +++++++ code/compiler/13/examples/errors/pattern_too_few_args.txt | 8 ++++++++ .../compiler/13/examples/errors/pattern_too_many_args.txt | 8 ++++++++ .../13/examples/errors/pattern_unknown_constructor.txt | 6 ++++++ code/compiler/13/examples/errors/type_redefinition.txt | 1 + code/compiler/13/examples/errors/unknown_lid.txt | 3 +++ code/compiler/13/examples/errors/unknown_type.txt | 1 + code/compiler/13/examples/errors/unknown_type_param.txt | 1 + code/compiler/13/examples/errors/unknown_uid.txt | 3 +++ code/compiler/13/examples/errors/wrong_type_kind.txt | 1 + 15 files changed, 65 insertions(+) create mode 100644 code/compiler/13/examples/errors/double_catchall.txt create mode 100644 code/compiler/13/examples/errors/duplicate_type_param.txt create mode 100644 code/compiler/13/examples/errors/exhausted_patterns.txt create mode 100644 code/compiler/13/examples/errors/incomplete_patterns.txt create mode 100644 code/compiler/13/examples/errors/invalid_case_analysis.txt create mode 100644 code/compiler/13/examples/errors/match_after_catchall.txt create mode 100644 code/compiler/13/examples/errors/pattern_too_few_args.txt create mode 100644 code/compiler/13/examples/errors/pattern_too_many_args.txt create mode 100644 code/compiler/13/examples/errors/pattern_unknown_constructor.txt create mode 100644 code/compiler/13/examples/errors/type_redefinition.txt create mode 100644 code/compiler/13/examples/errors/unknown_lid.txt create mode 100644 code/compiler/13/examples/errors/unknown_type.txt create mode 100644 code/compiler/13/examples/errors/unknown_type_param.txt create mode 100644 code/compiler/13/examples/errors/unknown_uid.txt create mode 100644 code/compiler/13/examples/errors/wrong_type_kind.txt diff --git a/code/compiler/13/examples/errors/double_catchall.txt b/code/compiler/13/examples/errors/double_catchall.txt new file mode 100644 index 0000000..a8842ac --- /dev/null +++ b/code/compiler/13/examples/errors/double_catchall.txt @@ -0,0 +1,6 @@ +defn main = { + case True of { + n -> { 2 } + n -> { 1 } + } +} diff --git a/code/compiler/13/examples/errors/duplicate_type_param.txt b/code/compiler/13/examples/errors/duplicate_type_param.txt new file mode 100644 index 0000000..a89b59d --- /dev/null +++ b/code/compiler/13/examples/errors/duplicate_type_param.txt @@ -0,0 +1 @@ +data Pair a a = { MkPair a a } diff --git a/code/compiler/13/examples/errors/exhausted_patterns.txt b/code/compiler/13/examples/errors/exhausted_patterns.txt new file mode 100644 index 0000000..8ed206a --- /dev/null +++ b/code/compiler/13/examples/errors/exhausted_patterns.txt @@ -0,0 +1,7 @@ +defn main = { + case True of { + True -> { 1 } + False -> { 0 } + n -> { 2 } + } +} diff --git a/code/compiler/13/examples/errors/incomplete_patterns.txt b/code/compiler/13/examples/errors/incomplete_patterns.txt new file mode 100644 index 0000000..84f15d2 --- /dev/null +++ b/code/compiler/13/examples/errors/incomplete_patterns.txt @@ -0,0 +1,5 @@ +defn main = { + case True of { + True -> { 1 } + } +} diff --git a/code/compiler/13/examples/errors/invalid_case_analysis.txt b/code/compiler/13/examples/errors/invalid_case_analysis.txt new file mode 100644 index 0000000..1a330bf --- /dev/null +++ b/code/compiler/13/examples/errors/invalid_case_analysis.txt @@ -0,0 +1,7 @@ +defn add x y = { x + y } + +defn main = { + case add of { + n -> { 1 } + } +} diff --git a/code/compiler/13/examples/errors/match_after_catchall.txt b/code/compiler/13/examples/errors/match_after_catchall.txt new file mode 100644 index 0000000..588f213 --- /dev/null +++ b/code/compiler/13/examples/errors/match_after_catchall.txt @@ -0,0 +1,7 @@ +defn main = { + case True of { + n -> { 2 } + True -> { 1 } + False -> { 0 } + } +} diff --git a/code/compiler/13/examples/errors/pattern_too_few_args.txt b/code/compiler/13/examples/errors/pattern_too_few_args.txt new file mode 100644 index 0000000..229ff62 --- /dev/null +++ b/code/compiler/13/examples/errors/pattern_too_few_args.txt @@ -0,0 +1,8 @@ +data List = { Nil, Cons Int List } + +defn head l = { + case l of { + Nil -> { 0 } + Cons x -> { x } + } +} diff --git a/code/compiler/13/examples/errors/pattern_too_many_args.txt b/code/compiler/13/examples/errors/pattern_too_many_args.txt new file mode 100644 index 0000000..6f82b3d --- /dev/null +++ b/code/compiler/13/examples/errors/pattern_too_many_args.txt @@ -0,0 +1,8 @@ +data List = { Nil, Cons Int List } + +defn head l = { + case l of { + Nil -> { 0 } + Cons x y z -> { x } + } +} diff --git a/code/compiler/13/examples/errors/pattern_unknown_constructor.txt b/code/compiler/13/examples/errors/pattern_unknown_constructor.txt new file mode 100644 index 0000000..ea79da8 --- /dev/null +++ b/code/compiler/13/examples/errors/pattern_unknown_constructor.txt @@ -0,0 +1,6 @@ +defn main = { + case True of { + NotBool -> { 1 } + True -> { 2 } + } +} diff --git a/code/compiler/13/examples/errors/type_redefinition.txt b/code/compiler/13/examples/errors/type_redefinition.txt new file mode 100644 index 0000000..da359ed --- /dev/null +++ b/code/compiler/13/examples/errors/type_redefinition.txt @@ -0,0 +1 @@ +data Bool = { True, False } diff --git a/code/compiler/13/examples/errors/unknown_lid.txt b/code/compiler/13/examples/errors/unknown_lid.txt new file mode 100644 index 0000000..8b735f4 --- /dev/null +++ b/code/compiler/13/examples/errors/unknown_lid.txt @@ -0,0 +1,3 @@ +defn main = { + weird 1 +} diff --git a/code/compiler/13/examples/errors/unknown_type.txt b/code/compiler/13/examples/errors/unknown_type.txt new file mode 100644 index 0000000..b17668f --- /dev/null +++ b/code/compiler/13/examples/errors/unknown_type.txt @@ -0,0 +1 @@ +data Wrapper = { Wrap Weird } diff --git a/code/compiler/13/examples/errors/unknown_type_param.txt b/code/compiler/13/examples/errors/unknown_type_param.txt new file mode 100644 index 0000000..98fbd88 --- /dev/null +++ b/code/compiler/13/examples/errors/unknown_type_param.txt @@ -0,0 +1 @@ +data Wrapper = { Wrap a } diff --git a/code/compiler/13/examples/errors/unknown_uid.txt b/code/compiler/13/examples/errors/unknown_uid.txt new file mode 100644 index 0000000..0bbf2a3 --- /dev/null +++ b/code/compiler/13/examples/errors/unknown_uid.txt @@ -0,0 +1,3 @@ +defn main = { + Weird 1 +} diff --git a/code/compiler/13/examples/errors/wrong_type_kind.txt b/code/compiler/13/examples/errors/wrong_type_kind.txt new file mode 100644 index 0000000..5e14674 --- /dev/null +++ b/code/compiler/13/examples/errors/wrong_type_kind.txt @@ -0,0 +1 @@ +data Wrapper = { Wrap (Int Bool) }