@@ -1105,7 +1105,9 @@ fn parse_string_size_expression(lexer: &mut ParseSession) -> Option<AstNode> {
11051105 . with_location ( error_range)
11061106 . with_error_code ( "E009" ) ,
11071107 ) ;
1108- } else if !is_enum_like && ( opening_token == KeywordParensOpen || lexer. token == KeywordParensClose ) {
1108+ } else if !is_enum_like
1109+ && ( opening_token == KeywordParensOpen || lexer. token == KeywordParensClose )
1110+ {
11091111 lexer. accept_diagnostic ( Diagnostic :: new (
11101112 "Unusual type of parentheses around string size expression, consider using square parentheses '[]'" ) .
11111113 with_location ( error_range)
@@ -1135,21 +1137,14 @@ fn parse_string_type_definition(
11351137
11361138 // Check if this is actually an enum type (e.g., STRING (a := 1, b := 2))
11371139 // If size is an ExpressionList with assignments, it's likely an invalid enum definition
1138- let is_enum_like = matches ! (
1139- & size,
1140- Some ( AstNode { stmt: AstStatement :: ExpressionList ( _) , .. } )
1141- ) ;
1140+ let is_enum_like = matches ! ( & size, Some ( AstNode { stmt: AstStatement :: ExpressionList ( _) , .. } ) ) ;
11421141
11431142 match ( size, & name, is_enum_like) {
11441143 ( Some ( size) , _, true ) => {
11451144 // This looks like an enum definition with STRING/WSTRING as the type
11461145 // Create an EnumType so validation can catch it as invalid
11471146 Some ( DataTypeDeclaration :: Definition {
1148- data_type : Box :: new ( DataType :: EnumType {
1149- name,
1150- numeric_type : text,
1151- elements : size,
1152- } ) ,
1147+ data_type : Box :: new ( DataType :: EnumType { name, numeric_type : text, elements : size } ) ,
11531148 location,
11541149 scope : lexer. scope . clone ( ) ,
11551150 } )
@@ -1189,11 +1184,8 @@ fn parse_enum_type_definition(
11891184
11901185 // Check for Codesys-style type specification after the enum list
11911186 // TYPE COLOR : (...) DWORD;
1192- let numeric_type = if lexer. token == Identifier {
1193- lexer. slice_and_advance ( )
1194- } else {
1195- DINT_TYPE . to_string ( )
1196- } ;
1187+ let numeric_type =
1188+ if lexer. token == Identifier { lexer. slice_and_advance ( ) } else { DINT_TYPE . to_string ( ) } ;
11971189
11981190 let initializer = lexer. try_consume ( KeywordAssignment ) . then ( || parse_expression ( lexer) ) ;
11991191 Some ( (
0 commit comments