Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix body expr span #2402

Merged
merged 1 commit into from Aug 22, 2023
Merged
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 crates/noirc_frontend/src/parser/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@
.then(parenthesized(function_parameters(allow_self)))
.then(function_return_type())
.then(where_clause())
.then(block(expression()))
.validate(|(((args, ret), where_clause), body), span, emit| {
.then(spanned(block(expression())))
.validate(|(((args, ret), where_clause), (body, body_span)), span, emit| {
let ((((attribute, modifiers), name), generics), parameters) = args;
validate_where_clause(&generics, &where_clause, span, emit);
FunctionDefinition {
span: name.0.span(),
span: body_span,
name,
attribute, // XXX: Currently we only have one attribute defined. If more attributes are needed per function, we can make this a vector and make attribute definition more expressive
is_unconstrained: modifiers.0,
Expand Down Expand Up @@ -331,10 +331,10 @@
}

fn self_parameter() -> impl NoirParser<(Pattern, UnresolvedType, Visibility)> {
let refmut_pattern = just(Token::Ampersand).then_ignore(keyword(Keyword::Mut));

Check warning on line 334 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (refmut)
let mut_pattern = keyword(Keyword::Mut);

refmut_pattern

Check warning on line 337 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (refmut)
.or(mut_pattern)
.map_with_span(|token, span| (token, span))
.or_not()
Expand Down Expand Up @@ -775,7 +775,7 @@
let shorthand_operators = right_shift_operator().or(one_of(shorthand_operators));
let shorthand_syntax = shorthand_operators.then_ignore(just(Token::Assign));

// Since >> is lexed as two separate greater-thans, >>= is lexed as > >=, so

Check warning on line 778 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (thans)
// we need to account for that case here as well.
let right_shift_fix =
just(Token::Greater).then(just(Token::GreaterEqual)).map(|_| Token::ShiftRight);
Expand Down Expand Up @@ -803,7 +803,7 @@

let dereferences = just(Token::Star).repeated();

let lvalues =

Check warning on line 806 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (lvalues)
l_ident.then(l_member_rhs.or(l_index).repeated()).foldl(|lvalue, rhs| match rhs {
LValueRhs::MemberAccess(field_name) => {
LValue::MemberAccess { object: Box::new(lvalue), field_name }
Expand All @@ -811,7 +811,7 @@
LValueRhs::Index(index) => LValue::Index { array: Box::new(lvalue), index },
});

dereferences.then(lvalues).foldr(|_, lvalue| LValue::Dereference(Box::new(lvalue)))

Check warning on line 814 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (lvalues)

Check warning on line 814 in crates/noirc_frontend/src/parser/parser.rs

View workflow job for this annotation

GitHub Actions / Spellcheck / Spellcheck

Unknown word (foldr)
}

fn parse_type<'a>() -> impl NoirParser<UnresolvedType> + 'a {
Expand Down