diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 54c944e9..b1d2a7c2 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -777,6 +777,13 @@ impl AssignmentKind { pub fn is_expect(&self) -> bool { matches!(self, AssignmentKind::Expect) } + + pub fn location_offset(&self) -> usize { + match self { + AssignmentKind::Let => 3, + AssignmentKind::Expect => 6, + } + } } pub type MultiPattern = Vec>; diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index 919be51f..cb745d35 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -906,7 +906,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> { .push(Warning::SingleConstructorExpect { location: Span { start: location.start, - end: location.start + 6, + end: kind.location_offset(), }, pattern_location: dbg!(untyped_pattern.location()), value_location: dbg!(untyped_value.location()), diff --git a/crates/aiken-lang/src/tipo/infer.rs b/crates/aiken-lang/src/tipo/infer.rs index 771c5d0c..2aead900 100644 --- a/crates/aiken-lang/src/tipo/infer.rs +++ b/crates/aiken-lang/src/tipo/infer.rs @@ -20,6 +20,8 @@ use super::{ TypeInfo, ValueConstructor, ValueConstructorVariant, }; +const PUB_OFFSET: usize = 3; + impl UntypedModule { pub fn infer( mut self, @@ -162,7 +164,7 @@ fn infer_definition( environment.warnings.push(Warning::PubInValidatorModule { location: Span { start: location.start, - end: location.start + 3, + end: location.start + PUB_OFFSET, }, }) } @@ -270,7 +272,7 @@ fn infer_definition( environment.warnings.push(Warning::PubInValidatorModule { location: Span { start: location.start, - end: location.start + 3, + end: location.start + PUB_OFFSET, }, }) } @@ -306,7 +308,7 @@ fn infer_definition( environment.warnings.push(Warning::PubInValidatorModule { location: Span { start: location.start, - end: location.start + 3, + end: location.start + PUB_OFFSET, }, }) } @@ -449,7 +451,7 @@ fn infer_definition( environment.warnings.push(Warning::PubInValidatorModule { location: Span { start: location.start, - end: location.start + 3, + end: location.start + PUB_OFFSET, }, }) }