Skip to content

Commit

Permalink
fix: correct span for prefix operator (#5624)
Browse files Browse the repository at this point in the history
# Description

## Problem

Resolves #5523

## Summary

The span of a Prefix expression was taken from its prefixed expression
instead of from the entire expression.

## Additional Context

I'm not sure how to test this 🤔 

## 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 Jul 29, 2024
1 parent f894c7d commit 9100558
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler/noirc_frontend/src/elaborator/expressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl<'context> Elaborator<'context> {
let (hir_expr, typ) = match expr.kind {
ExpressionKind::Literal(literal) => self.elaborate_literal(literal, expr.span),
ExpressionKind::Block(block) => self.elaborate_block(block),
ExpressionKind::Prefix(prefix) => return self.elaborate_prefix(*prefix),
ExpressionKind::Prefix(prefix) => return self.elaborate_prefix(*prefix, expr.span),
ExpressionKind::Index(index) => self.elaborate_index(*index),
ExpressionKind::Call(call) => self.elaborate_call(*call, expr.span),
ExpressionKind::MethodCall(call) => self.elaborate_method_call(*call, expr.span),
Expand Down Expand Up @@ -225,8 +225,7 @@ impl<'context> Elaborator<'context> {
(HirExpression::Literal(HirLiteral::FmtStr(str, fmt_str_idents)), typ)
}

fn elaborate_prefix(&mut self, prefix: PrefixExpression) -> (ExprId, Type) {
let span = prefix.rhs.span;
fn elaborate_prefix(&mut self, prefix: PrefixExpression, span: Span) -> (ExprId, Type) {
let (rhs, rhs_type) = self.elaborate_expression(prefix.rhs);
let trait_id = self.interner.get_prefix_operator_trait_method(&prefix.operator);

Expand Down

0 comments on commit 9100558

Please sign in to comment.