@@ -743,7 +743,8 @@ fn type_declaration(&mut self) -> TypeDeclaration {
743
743
}
744
744
745
745
fn constrained_type ( & mut self ) -> ( Vec < Constraint > , Type ) {
746
- let mut maybeConstraints = if self . lexer . next ( ) . token == LPARENS {
746
+ debug ! ( "Parse constrained type" ) ;
747
+ let mut maybe_constraints = if self . lexer . next ( ) . token == LPARENS {
747
748
if self . lexer . peek ( ) . token == RPARENS {
748
749
self . lexer . next ( ) ;
749
750
vec ! [ ]
@@ -758,27 +759,28 @@ fn constrained_type(&mut self) -> (Vec<Constraint>, Type) {
758
759
self . lexer . backtrack ( ) ;
759
760
vec ! [ self . parse_type( ) ]
760
761
} ;
761
- let maybeContextArrow = self . lexer . next ( ) . token ;
762
+ debug ! ( "{:?}" , maybe_constraints ) ;
762
763
//If there is => arrow we proceed to parse the type
763
- let typ = if maybeContextArrow == CONTEXTARROW {
764
- self . parse_type ( )
765
- }
766
- else if maybeContextArrow == ARROW {
767
- self . lexer . backtrack ( ) ;
768
- let mut args = Vec :: new ( ) ;
769
- swap ( & mut args , & mut maybeConstraints ) ;
770
- self . parse_return_type ( make_tuple_type ( args ) )
771
- }
772
- else { //If no => was found, translate the constraint list into a type
773
- self . lexer . backtrack ( ) ;
774
- let mut args = Vec :: new ( ) ;
775
- swap ( & mut args , & mut maybeConstraints ) ;
776
- make_tuple_type ( args )
764
+ let typ = match self . lexer . next ( ) . token {
765
+ CONTEXTARROW => self . parse_type ( ) ,
766
+ ARROW => {
767
+ self . lexer . backtrack ( ) ;
768
+ let mut args = Vec :: new ( ) ;
769
+ swap ( & mut args, & mut maybe_constraints ) ;
770
+ self . parse_return_type ( make_tuple_type ( args ) )
771
+ }
772
+ _ => { //If no => was found, translate the constraint list into a type
773
+ self . lexer . backtrack ( ) ;
774
+ let mut args = Vec :: new ( ) ;
775
+ swap ( & mut args, & mut maybe_constraints ) ;
776
+ make_tuple_type ( args )
777
+ }
777
778
} ;
778
- ( make_constraints ( maybeConstraints ) , typ)
779
+ ( make_constraints ( maybe_constraints ) , typ)
779
780
}
780
781
781
782
fn constructor_type ( & mut self , arity : & mut isize , dataDef : & DataDefinition ) -> Type {
783
+ debug ! ( "Parse constructor type" ) ;
782
784
let token = self . lexer . next ( ) . token ;
783
785
if token == NAME {
784
786
* arity += 1 ;
0 commit comments