From 231a72f2eea698b6783274e08fa021f193d4abfd Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Wed, 12 Oct 2022 10:39:00 -0500 Subject: [PATCH] Insert first ability correctly in the parser --- crates/compiler/parse/src/type_annotation.rs | 2 +- ...e_multiple_bound_abilities.expr.result-ast | 56 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/crates/compiler/parse/src/type_annotation.rs b/crates/compiler/parse/src/type_annotation.rs index 83816fcc3f..4b4557a304 100644 --- a/crates/compiler/parse/src/type_annotation.rs +++ b/crates/compiler/parse/src/type_annotation.rs @@ -438,7 +438,7 @@ fn ability_chain<'a>( Loc>, Vec<'a, Loc>> )| { - other_abilities.push(first_ability); + other_abilities.insert(0, first_ability); other_abilities } ) diff --git a/crates/compiler/parse/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast b/crates/compiler/parse/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast index c5de27a60c..7d98f8dc03 100644 --- a/crates/compiler/parse/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast +++ b/crates/compiler/parse/tests/snapshots/pass/where_clause_multiple_bound_abilities.expr.result-ast @@ -5,8 +5,8 @@ Defs( Index(2147483649), ], regions: [ - @0-38, - @57-103, + @0-55, + @57-118, ], space_before: [ Slice(start = 0, length = 0), @@ -26,7 +26,7 @@ Defs( @0-1 Identifier( "f", ), - @4-38 Where( + @4-55 Where( @4-10 Function( [ @4-5 BoundVariable( @@ -38,24 +38,29 @@ Defs( ), ), [ - @13-23 HasClause { + @13-28 HasClause { var: @13-14 "a", abilities: [ - @26-28 Apply( - "", - "Eq", - [], - ), @19-23 Apply( "", "Hash", [], ), + @26-28 Apply( + "", + "Eq", + [], + ), ], }, - @30-38 HasClause { + @30-55 HasClause { var: @30-31 "b", abilities: [ + @36-38 Apply( + "", + "Eq", + [], + ), @41-45 Apply( "", "Hash", @@ -66,11 +71,6 @@ Defs( "Display", [], ), - @36-38 Apply( - "", - "Eq", - [], - ), ], }, ], @@ -80,7 +80,7 @@ Defs( @57-58 Identifier( "f", ), - @61-103 Where( + @61-118 Where( @61-67 SpaceBefore( Function( [ @@ -97,22 +97,22 @@ Defs( ], ), [ - @72-82 HasClause { + @72-87 HasClause { var: @72-73 "a", abilities: [ - @85-87 Apply( - "", - "Eq", - [], - ), @78-82 Apply( "", "Hash", [], ), + @85-87 Apply( + "", + "Eq", + [], + ), ], }, - @93-103 HasClause { + @93-118 HasClause { var: @93-94 SpaceBefore( "b", [ @@ -120,6 +120,11 @@ Defs( ], ), abilities: [ + @99-103 Apply( + "", + "Hash", + [], + ), @106-113 Apply( "", "Display", @@ -130,11 +135,6 @@ Defs( "Eq", [], ), - @99-103 Apply( - "", - "Hash", - [], - ), ], }, ],