Skip to content

Commit

Permalink
Remove unnecessary semicolons from the grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Mackie authored and Jordan Mackie committed Jan 18, 2023
1 parent e0401de commit bcd54d6
Show file tree
Hide file tree
Showing 454 changed files with 2,209 additions and 2,258 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ pub fn kindcheck_foreign_value_declarations(
foreign_keyword,
name,
type_annotation,
semicolon,
} in foreign_value_declarations
{
let span = foreign_keyword.0.get_span().merge(&semicolon.0.get_span());
let span = foreign_keyword
.0
.get_span()
.merge(&type_annotation.get_span());
let mut state = kindchecker::State::default();
let foreign_type = typechecker::pre_ast::check_type_annotation(
env_types,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! assert_type_declaration_error {

macro_rules! parse_type_declaration {
($decl:expr) => {{
let parse_result = ditto_cst::TypeDeclaration::parse(&format!("{};", $decl));
let parse_result = ditto_cst::TypeDeclaration::parse($decl);
assert!(
matches!(parse_result, Ok(_)),
"{:#?}",
Expand All @@ -85,7 +85,7 @@ macro_rules! parse_type_declaration {

macro_rules! parse_type_alias_declaration {
($decl:expr) => {{
let parse_result = ditto_cst::TypeAliasDeclaration::parse(&format!("{};", $decl));
let parse_result = ditto_cst::TypeAliasDeclaration::parse($decl);
assert!(
matches!(parse_result, Ok(_)),
"{:#?}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ macro_rules! assert_value_declaration_error {

macro_rules! parse_value_declaration {
($decl:expr) => {{
let parse_result = ditto_cst::ValueDeclaration::parse(&format!("{};", $decl));
let parse_result = ditto_cst::ValueDeclaration::parse($decl);
assert!(
matches!(parse_result, Ok(_)),
"{:#?}",
Expand Down
68 changes: 34 additions & 34 deletions crates/ditto-checker/src/typechecker/coverage/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@ use macros::assert_not_covered;
fn it_errors_for_non_exhaustive_patterns() {
assert_not_covered!(
r#"
module Test exports (..);
type Foo = A | B;
test = fn (x: Foo) -> match x with | A -> 5 end;
module Test exports (..)
type Foo = A | B
test = fn (x: Foo) -> match x with | A -> 5 end
"#,
&["B"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
test = fn (x: Maybe(a)) -> match x with | Just(a) -> a end;
module Test exports (..)
type Maybe(a) = Just(a) | None
test = fn (x: Maybe(a)) -> match x with | Just(a) -> a end
"#,
&["None"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
test = fn (x: Maybe(Int)) -> match x with | None -> 2 end;
module Test exports (..)
type Maybe(a) = Just(a) | None
test = fn (x: Maybe(Int)) -> match x with | None -> 2 end
"#,
&["Just(_)"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
test = fn (x) -> match x with | Just(None) -> 2 end;
module Test exports (..)
type Maybe(a) = Just(a) | None
test = fn (x) -> match x with | Just(None) -> 2 end
"#,
&["None", "Just(Just(_))"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
test = fn (x) -> match x with | Just(Just(Just(None))) -> 2 end;
module Test exports (..)
type Maybe(a) = Just(a) | None
test = fn (x) -> match x with | Just(Just(Just(None))) -> 2 end
"#,
&[
"None",
Expand All @@ -49,28 +49,28 @@ fn it_errors_for_non_exhaustive_patterns() {
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
type Result(a, e) = Ok(a) | Err(e);
test = fn (x: Result(Maybe(Maybe(Int)), String)) -> match x with | Err(str) -> str end;
module Test exports (..)
type Maybe(a) = Just(a) | None
type Result(a, e) = Ok(a) | Err(e)
test = fn (x: Result(Maybe(Maybe(Int)), String)) -> match x with | Err(str) -> str end
"#,
&["Ok(_)"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
type Result(a, e) = Ok(a) | Err(e);
test = fn (x: Result(Maybe(Maybe(Int)), String)) -> match x with | Ok(Just(None)) -> "noice" end;
module Test exports (..)
type Maybe(a) = Just(a) | None
type Result(a, e) = Ok(a) | Err(e)
test = fn (x: Result(Maybe(Maybe(Int)), String)) -> match x with | Ok(Just(None)) -> "noice" end
"#,
&["Err(_)", "Ok(None)", "Ok(Just(Just(_)))"]
);
assert_not_covered!(
r#"
module Test exports (..);
type Maybe(a) = Just(a) | None;
type A = A(Maybe(Maybe(Int)));
test = fn (a: A) -> match a with | A(Just(Just(n))) -> "yeh?" end;
module Test exports (..)
type Maybe(a) = Just(a) | None
type A = A(Maybe(Maybe(Int)))
test = fn (a: A) -> match a with | A(Just(Just(n))) -> "yeh?" end
"#,
&["A(None)", "A(Just(None))"]
);
Expand All @@ -82,14 +82,14 @@ fn it_errors_for_non_exhaustive_patterns() {
// Would be nice if we could qualify only when needed?
assert_not_covered!(
r#"
module Test exports (..);
import (test-stuff) Data.Stuff as A;
import Data.Stuff as B;
module Test exports (..)
import (test-stuff) Data.Stuff as A
import Data.Stuff as B
option_of_option = fn (oo) ->
match oo with
| A.Some(B.None) -> unit
end;
end
"#,
&["None", "Some(Some(_))"],
&mk_everything()
Expand All @@ -102,9 +102,9 @@ fn mk_everything() -> crate::Everything {
module Data.Stuff exports (
Five(..),
Option(..),
);
type Option(a) = Some(a) | None;
type Five = Five;
)
type Option(a) = Some(a) | None
type Five = Five
"#,
);

Expand Down
6 changes: 3 additions & 3 deletions crates/ditto-checker/src/typechecker/tests/let.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use crate::Warning::*;

#[test]
fn it_typechecks_as_expected() {
assert_type!("let five : Int = 5; in five", "Int");
assert_type!("let five : Int = 5 in five", "Int");
assert_type!(
"let five : Int = 5; fives = [five, five, five]; in fives",
"let five : Int = 5 fives = [five, five, five] in fives",
"Array(Int)"
);
}

#[test]
fn it_warns_as_expected() {
assert_type!("let five = 5; in unit", "Unit", [UnusedLetBinder { .. }]);
assert_type!("let five = 5 in unit", "Unit", [UnusedLetBinder { .. }]);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Test exports (..);
module Test exports (..)

always = fn (a) -> fn (_b) -> a;
five: Int = always(5)(true);
always = fn (a) -> fn (_b) -> a
five: Int = always(5)(true)

always_five: (a) -> Int = always(5);
another_five: Int = always_five(unit);
always_five: (a) -> Int = always(5)
another_five: Int = always_five(unit)
Loading

0 comments on commit bcd54d6

Please sign in to comment.