From 5e50ad90b01ef5f589515280668187b722bfcb5f Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Tue, 4 Feb 2020 19:04:27 +0000 Subject: Implement typechecking of toMap --- dhall/tests/type-errors/unit/EmptyToMap.txt | 6 ++++++ dhall/tests/type-errors/unit/HeterogenousToMap.txt | 6 ++++++ dhall/tests/type-errors/unit/MistypedToMap1.txt | 6 ++++++ dhall/tests/type-errors/unit/MistypedToMap2.txt | 6 ++++++ dhall/tests/type-errors/unit/MistypedToMap3.txt | 6 ++++++ dhall/tests/type-errors/unit/MistypedToMap4.txt | 6 ++++++ dhall/tests/type-errors/unit/NonRecordToMap.txt | 6 ++++++ dhall/tests/type-errors/unit/ToMapEmptyInvalidAnnotation.txt | 7 +++++++ dhall/tests/type-errors/unit/ToMapWrongKind.txt | 6 ++++++ 9 files changed, 55 insertions(+) create mode 100644 dhall/tests/type-errors/unit/EmptyToMap.txt create mode 100644 dhall/tests/type-errors/unit/HeterogenousToMap.txt create mode 100644 dhall/tests/type-errors/unit/MistypedToMap1.txt create mode 100644 dhall/tests/type-errors/unit/MistypedToMap2.txt create mode 100644 dhall/tests/type-errors/unit/MistypedToMap3.txt create mode 100644 dhall/tests/type-errors/unit/MistypedToMap4.txt create mode 100644 dhall/tests/type-errors/unit/NonRecordToMap.txt create mode 100644 dhall/tests/type-errors/unit/ToMapEmptyInvalidAnnotation.txt create mode 100644 dhall/tests/type-errors/unit/ToMapWrongKind.txt (limited to 'dhall/tests/type-errors/unit') diff --git a/dhall/tests/type-errors/unit/EmptyToMap.txt b/dhall/tests/type-errors/unit/EmptyToMap.txt new file mode 100644 index 0000000..000fac7 --- /dev/null +++ b/dhall/tests/type-errors/unit/EmptyToMap.txt @@ -0,0 +1,6 @@ +Type error: error: `toMap` applied to an empty record requires a type annotation + --> :1:0 + | +1 | toMap {=} + | ^^^^^^^^^ `toMap` applied to an empty record requires a type annotation + | diff --git a/dhall/tests/type-errors/unit/HeterogenousToMap.txt b/dhall/tests/type-errors/unit/HeterogenousToMap.txt new file mode 100644 index 0000000..2f8abf2 --- /dev/null +++ b/dhall/tests/type-errors/unit/HeterogenousToMap.txt @@ -0,0 +1,6 @@ +Type error: error: Every field of the record must have the same type + --> :1:0 + | +1 | toMap { foo= 1, bar= "Bar" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Every field of the record must have the same type + | diff --git a/dhall/tests/type-errors/unit/MistypedToMap1.txt b/dhall/tests/type-errors/unit/MistypedToMap1.txt new file mode 100644 index 0000000..14d9791 --- /dev/null +++ b/dhall/tests/type-errors/unit/MistypedToMap1.txt @@ -0,0 +1,6 @@ +Type error: error: Annotation mismatch + --> :1:0 + | +1 | toMap { foo= 1, bar= 4 } : Natural + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Annotation mismatch + | diff --git a/dhall/tests/type-errors/unit/MistypedToMap2.txt b/dhall/tests/type-errors/unit/MistypedToMap2.txt new file mode 100644 index 0000000..88e303e --- /dev/null +++ b/dhall/tests/type-errors/unit/MistypedToMap2.txt @@ -0,0 +1,6 @@ +Type error: error: Annotation mismatch + --> :1:0 + | +1 | toMap { foo= 1, bar= 4 } : List Natural + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Annotation mismatch + | diff --git a/dhall/tests/type-errors/unit/MistypedToMap3.txt b/dhall/tests/type-errors/unit/MistypedToMap3.txt new file mode 100644 index 0000000..6b3772d --- /dev/null +++ b/dhall/tests/type-errors/unit/MistypedToMap3.txt @@ -0,0 +1,6 @@ +Type error: error: Annotation mismatch + --> :1:0 + | +1 | toMap { foo= 1, bar= 4 } : List { mapKey : Natural, mapValue : Natural } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Annotation mismatch + | diff --git a/dhall/tests/type-errors/unit/MistypedToMap4.txt b/dhall/tests/type-errors/unit/MistypedToMap4.txt new file mode 100644 index 0000000..e0cf651 --- /dev/null +++ b/dhall/tests/type-errors/unit/MistypedToMap4.txt @@ -0,0 +1,6 @@ +Type error: error: Annotation mismatch + --> :1:0 + | +1 | toMap { foo= 1, bar= 4 } : List { mapKey : Text, mapValue : Text } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Annotation mismatch + | diff --git a/dhall/tests/type-errors/unit/NonRecordToMap.txt b/dhall/tests/type-errors/unit/NonRecordToMap.txt new file mode 100644 index 0000000..8e83002 --- /dev/null +++ b/dhall/tests/type-errors/unit/NonRecordToMap.txt @@ -0,0 +1,6 @@ +Type error: error: The argument to `toMap` must be a record + --> :1:0 + | +1 | toMap "text" + | ^^^^^^^^^^^^ The argument to `toMap` must be a record + | diff --git a/dhall/tests/type-errors/unit/ToMapEmptyInvalidAnnotation.txt b/dhall/tests/type-errors/unit/ToMapEmptyInvalidAnnotation.txt new file mode 100644 index 0000000..c28073e --- /dev/null +++ b/dhall/tests/type-errors/unit/ToMapEmptyInvalidAnnotation.txt @@ -0,0 +1,7 @@ +Type error: error: The type of `toMap x` must be of the form `List { mapKey : Text, mapValue : T }` + --> :2:0 + | +1 | -- The mapKey must be Text +2 | toMap {=} : List { mapKey : Bool, mapValue : Text } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The type of `toMap x` must be of the form `List { mapKey : Text, mapValue : T }` + | diff --git a/dhall/tests/type-errors/unit/ToMapWrongKind.txt b/dhall/tests/type-errors/unit/ToMapWrongKind.txt new file mode 100644 index 0000000..8158c08 --- /dev/null +++ b/dhall/tests/type-errors/unit/ToMapWrongKind.txt @@ -0,0 +1,6 @@ +Type error: error: `toMap` only accepts records of type `Type` + --> :1:0 + | +1 | toMap { x = Bool } + | ^^^^^^^^^^^^^^^^^^ `toMap` only accepts records of type `Type` + | -- cgit v1.2.3