diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fbdcd0a4a..aae5f7f299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ read the notes of the `Enso 2.0.0-alpha.1` release. acting as a loading progress indicator completed too quickly and stopped spinning before IDE was ready. Now it stays active, giving a visual indication that the initialization is still in progress. +- [Include parser fixes][1274]. The parser used in the IDE has been updated to the latest version. + This resolves several issues with language constructs like `import`, lambdas and parentheses, + where upon entering certain text, the edit could be automatically reverted. #### EnsoGL - New multi-camera management system, allowing the same shape systems be rendered on different @@ -65,6 +68,7 @@ read the notes of the `Enso 2.0.0-alpha.1` release. [1187]: https://github.com/enso-org/ide/pull/1187 [1214]: https://github.com/enso-org/ide/pull/1214 [1237]: https://github.com/enso-org/ide/pull/1237 +[1237]: https://github.com/enso-org/ide/pull/1274
diff --git a/src/rust/ide/lib/ast/impl/src/crumbs.rs b/src/rust/ide/lib/ast/impl/src/crumbs.rs index 86eba8bb61..f717b031ac 100644 --- a/src/rust/ide/lib/ast/impl/src/crumbs.rs +++ b/src/rust/ide/lib/ast/impl/src/crumbs.rs @@ -2029,7 +2029,7 @@ mod tests { head : MacroMatchSegment{head:var.clone(),body:body.clone()}, tail : vec![] }; - Match{pfx:Some(body),segs,resolved:var.clone()} + Match{pfx:Some(body),segs,resolved:Some(var.clone())} } #[test] @@ -2068,7 +2068,7 @@ mod tests { let crumb6 = MatchCrumb::Segs{val:SegmentMatchCrumb::Body{val:crumb1},index:0}; let crumb7 = MatchCrumb::Segs{val:SegmentMatchCrumb::Body{val:crumb2},index:0}; let match1 = match_(); - let ast = [match1.resolved.clone(), Ast::var("X"), Ast::var("Y"), Ast::var("Z")]; + let ast = [match1.resolved.clone().unwrap(),Ast::var("X"),Ast::var("Y"),Ast::var("Z")]; let match2 = match1.set(&crumb3,ast[1].clone()).unwrap(); let match3 = match2.set(&crumb5,ast[2].clone()).unwrap(); let match4 = match3.set(&crumb7,ast[3].clone()).unwrap(); diff --git a/src/rust/ide/lib/ast/impl/src/lib.rs b/src/rust/ide/lib/ast/impl/src/lib.rs index c1c3201e8d..0eaea70e16 100644 --- a/src/rust/ide/lib/ast/impl/src/lib.rs +++ b/src/rust/ide/lib/ast/impl/src/lib.rs @@ -495,7 +495,7 @@ pub enum Shape { // === Macros === Match { pfx : Option>> , segs : ShiftedVec1> - , resolved : Ast }, + , resolved : Option }, Ambiguous { segs : ShiftedVec1> , paths : Tree }, diff --git a/src/rust/ide/lib/parser/build.rs b/src/rust/ide/lib/parser/build.rs index 4831b03847..97bbdd560d 100644 --- a/src/rust/ide/lib/parser/build.rs +++ b/src/rust/ide/lib/parser/build.rs @@ -25,7 +25,7 @@ use std::path::PathBuf; const PARSER_PATH: &str = "./pkg/scala-parser.js"; /// Commit from `enso` repository that will be used to obtain parser from. -const PARSER_COMMIT: &str = "2c5ed028aab74fa50747c5c9eaa1ec21ae0c5c07"; +const PARSER_COMMIT: &str = "fea88569709015363d053f28bbe6ada75b385321"; /// Magic code that needs to be prepended to ScalaJS generated parser due to: /// https://github.com/scala-js/scala-js/issues/3677/ diff --git a/src/rust/ide/lib/parser/tests/bugs.rs b/src/rust/ide/lib/parser/tests/bugs.rs index 0d1a57eb68..93c866cbc0 100644 --- a/src/rust/ide/lib/parser/tests/bugs.rs +++ b/src/rust/ide/lib/parser/tests/bugs.rs @@ -8,20 +8,6 @@ use wasm_bindgen_test::wasm_bindgen_test_configure; wasm_bindgen_test_configure!(run_in_browser); -#[wasm_bindgen_test] -fn missing_macro_segment() { - // TODO: should succeed - // https://github.com/enso-org/enso/issues/256 - assert!(parser::Parser::new_or_panic().parse_line("-> a").is_err()); -} - -#[wasm_bindgen_test] -fn nested_macros() { - // TODO: should succeed - // https://github.com/enso-org/enso/issues/256 or https://github.com/enso-org/enso/issues/343 - assert!(parser::Parser::new_or_panic().parse_line("(a -> b) -> c").is_err()); -} - #[wasm_bindgen_test] fn extension_operator_methods() { let ast = parser::Parser::new_or_panic().parse_line("Int.+").unwrap(); diff --git a/src/rust/ide/lib/parser/tests/macros.rs b/src/rust/ide/lib/parser/tests/macros.rs index f08369ae22..0d0153be24 100644 --- a/src/rust/ide/lib/parser/tests/macros.rs +++ b/src/rust/ide/lib/parser/tests/macros.rs @@ -27,7 +27,7 @@ fn import_utilities() { assert!(ast_as_import_match(&ast).is_none()); }; - // expect_import("import"); // TODO [mwu] https://github.com/enso-org/enso/issues/1016 + expect_import("import"); expect_import("import Foo"); expect_import("import Foo.Bar"); expect_import("import Foo.Bar.Baz"); @@ -39,6 +39,8 @@ fn import_utilities() { expect_not_import("type Foo as Bar"); expect_not_import("if Foo then Bar else Baz"); expect_not_import("Foo.Bar.Baz"); + expect_not_import("->"); + expect_not_import("export"); expect_not_import("export Foo"); expect_not_import("from Foo export all hiding Bar"); } @@ -63,7 +65,7 @@ fn recognizing_lambdas() { expect_lambda("a->b", "a", "b"); expect_lambda("foo->4+(4)", "foo", "4+(4)"); expect_lambda("a->b->c", "a", "b->c"); - // expect_lambda("(a->b)->c"); // TODO: Failing due to internal parser error: java.lang.NullPointerException + expect_lambda("(a->b)->c", "(a->b)", "c"); expect_not_lambda("(a->b)"); expect_not_lambda("a+b"); diff --git a/src/rust/ide/lib/parser/tests/parsing.rs b/src/rust/ide/lib/parser/tests/parsing.rs index 8a977ad83f..4eee51d3f0 100644 --- a/src/rust/ide/lib/parser/tests/parsing.rs +++ b/src/rust/ide/lib/parser/tests/parsing.rs @@ -404,10 +404,13 @@ impl Fixture { , "freeze bar" , "case foo of\n bar" , "import foo" + , "import" , "export bar" , "from bar import all" , "from bar export bo" , "a ->" + , "-> a" + , "(a -> b) -> c" ]; for macro_usage in macro_usages.iter() {