Skip to content

Commit

Permalink
Fix incorrect range for imports with alias and exposing
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmengels committed Oct 8, 2024
1 parent 6a07f48 commit 8c03929
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## [Unreleased]

- Fixed a bug where the range was incorrect for imports with both `as` and `exposing`.

## [7.3.6] - 2024-09-11

- The parser is stricter in a few cases where code that was incorrect (according to the Elm compiler) was successfully parsed: tuple patterns and tuple type annotations with more than 3 parts, non-associative operators (so no more `a < b < c`), lambda indentation
Expand Down
12 changes: 6 additions & 6 deletions src/Elm/Parser/Imports.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ importDefinition =
let
endRange : Range
endRange =
case maybeModuleAlias of
Just moduleAliasValue ->
case maybeExposingList of
Just exposingListValue ->
let
(Node range _) =
moduleAliasValue.syntax
exposingListValue.syntax
in
range

Nothing ->
case maybeExposingList of
Just exposingListValue ->
case maybeModuleAlias of
Just moduleAliasValue ->
let
(Node range _) =
exposingListValue.syntax
moduleAliasValue.syntax
in
range

Expand Down
2 changes: 1 addition & 1 deletion tests/Elm/Parser/ImportsTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ all =
\() ->
"import Foo as Bar exposing (..)"
|> expectAst
(Node { start = { row = 1, column = 1 }, end = { row = 1, column = 18 } }
(Node { start = { row = 1, column = 1 }, end = { row = 1, column = 32 } }
{ moduleName = Node { start = { row = 1, column = 8 }, end = { row = 1, column = 11 } } [ "Foo" ]
, moduleAlias = Just (Node { start = { row = 1, column = 15 }, end = { row = 1, column = 18 } } [ "Bar" ])
, exposingList =
Expand Down

0 comments on commit 8c03929

Please sign in to comment.