Skip to content

Commit

Permalink
fix: mutable global pattern didn't have a span (#6328)
Browse files Browse the repository at this point in the history
# Description

## Problem

Without a span, LSP's document symbol crashed.

## Summary

Replaces a default span with a correct one.

## Additional Context

## Documentation

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
asterite authored Oct 23, 2024
1 parent b820328 commit 5a6dae9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/noirc_frontend/src/parser/parser/global.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ impl<'a> Parser<'a> {

fn ident_to_pattern(ident: Ident, mutable: bool) -> Pattern {
if mutable {
Pattern::Mutable(Box::new(Pattern::Identifier(ident)), Span::default(), false)
let span = ident.span();
Pattern::Mutable(Box::new(Pattern::Identifier(ident)), span, false)
} else {
Pattern::Identifier(ident)
}
Expand Down Expand Up @@ -140,6 +141,8 @@ mod tests {
panic!("Expected identifier pattern");
};
assert_eq!("foo", name.to_string());
assert_eq!(pattern.span().start(), 11);
assert_eq!(pattern.span().end(), 14);
}

#[test]
Expand Down

0 comments on commit 5a6dae9

Please sign in to comment.