Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions compiler/noirc_frontend/src/parser/parser/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ impl Parser<'_> {
);

let visibility = Visibility::Private;
let typ =
UnresolvedType { typ: UnresolvedTypeData::Error, location: Location::dummy() };
let location = self.location_at_previous_token_end();
let typ = UnresolvedType { typ: UnresolvedTypeData::Error, location };
(visibility, typ)
} else {
(
Expand Down Expand Up @@ -328,7 +328,7 @@ fn empty_function(location: Location) -> FunctionDefinitionWithOptionalBody {
body: None,
location: Location::new(span, location.file),
where_clause: Vec::new(),
return_type: FunctionReturnType::Default(Location::dummy()),
return_type: FunctionReturnType::Default(Location::new(span, location.file)),
return_visibility: Visibility::Private,
}
}
Expand Down
11 changes: 5 additions & 6 deletions compiler/noirc_frontend/src/parser/parser/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,11 @@ impl Parser<'_> {

let Some(ident) = self.eat_ident() else {
self.eat_semicolon();
let location = self.location_at_previous_token_end();
return LetStatement {
pattern: ident_to_pattern(Ident::default(), mutable),
r#type: UnresolvedType {
typ: UnresolvedTypeData::Unspecified,
location: Location::dummy(),
},
expression: Expression { kind: ExpressionKind::Error, location: Location::dummy() },
r#type: UnresolvedType { typ: UnresolvedTypeData::Unspecified, location },
expression: Expression { kind: ExpressionKind::Error, location },
attributes,
comptime,
is_global_let,
Expand All @@ -48,7 +46,8 @@ impl Parser<'_> {
self.parse_expression_or_error()
} else {
self.push_error(ParserErrorReason::GlobalWithoutValue, pattern.location());
Expression { kind: ExpressionKind::Error, location: Location::dummy() }
let location = self.location_at_previous_token_end();
Expression { kind: ExpressionKind::Error, location }
};

self.eat_semicolon_or_error();
Expand Down
12 changes: 6 additions & 6 deletions compiler/noirc_frontend/src/parser/parser/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,18 @@ impl Parser<'_> {
let Some(name) = self.eat_ident() else {
self.expected_identifier();
self.eat_semicolons();
let location = self.location_at_previous_token_end();
return Some(TraitImplItemKind::Type {
name: Ident::default(),
alias: UnresolvedType {
typ: UnresolvedTypeData::Error,
location: Location::dummy(),
},
alias: UnresolvedType { typ: UnresolvedTypeData::Error, location },
});
};

let alias = if self.eat_assign() {
self.parse_type_or_error()
} else {
UnresolvedType { typ: UnresolvedTypeData::Error, location: Location::dummy() }
let location = self.location_at_previous_token_end();
UnresolvedType { typ: UnresolvedTypeData::Error, location }
};

self.eat_semicolon_or_error();
Expand Down Expand Up @@ -195,7 +194,8 @@ impl Parser<'_> {
self.parse_expression_or_error()
} else {
self.expected_token(Token::Assign);
Expression { kind: ExpressionKind::Error, location: Location::dummy() }
let location = self.location_at_previous_token_end();
Expression { kind: ExpressionKind::Error, location }
};

self.eat_semicolon_or_error();
Expand Down
8 changes: 3 additions & 5 deletions compiler/noirc_frontend/src/parser/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,11 @@ impl Parser<'_> {
}

fn empty_for_loop(&mut self, identifier: Ident, start_location: Location) -> ForLoopStatement {
let location = self.location_at_previous_token_end();
ForLoopStatement {
identifier,
range: ForRange::Array(Expression {
kind: ExpressionKind::Error,
location: Location::dummy(),
}),
block: Expression { kind: ExpressionKind::Error, location: Location::dummy() },
range: ForRange::Array(Expression { kind: ExpressionKind::Error, location }),
block: Expression { kind: ExpressionKind::Error, location },
location: self.location_since(start_location),
}
}
Expand Down
3 changes: 2 additions & 1 deletion compiler/noirc_frontend/src/parser/parser/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ impl Parser<'_> {
self.parse_type_or_error()
} else {
self.expected_token(Token::Colon);
UnresolvedType { typ: UnresolvedTypeData::Unspecified, location: Location::dummy() }
let location = self.location_at_previous_token_end();
UnresolvedType { typ: UnresolvedTypeData::Unspecified, location }
};

let default_value =
Expand Down
8 changes: 6 additions & 2 deletions compiler/noirc_frontend/src/parser/parser/type_alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ impl Parser<'_> {
) -> NoirTypeAlias {
let Some(name) = self.eat_ident() else {
self.expected_identifier();
let location = self.location_at_previous_token_end();
return NoirTypeAlias {
visibility,
name: Ident::default(),
generics: Vec::new(),
typ: UnresolvedType { typ: UnresolvedTypeData::Error, location: Location::dummy() },
typ: UnresolvedType { typ: UnresolvedTypeData::Error, location },
location: start_location,
};
};
Expand All @@ -37,7 +38,10 @@ impl Parser<'_> {
visibility,
name,
generics,
typ: UnresolvedType { typ: UnresolvedTypeData::Error, location: Location::dummy() },
typ: UnresolvedType {
typ: UnresolvedTypeData::Error,
location: self.location_at_previous_token_end(),
},
location,
};
}
Expand Down
Loading