chore: no more loose numbers for location offsets
This commit is contained in:
parent
b803332f99
commit
461aaf14bd
|
@ -777,6 +777,13 @@ impl AssignmentKind {
|
||||||
pub fn is_expect(&self) -> bool {
|
pub fn is_expect(&self) -> bool {
|
||||||
matches!(self, AssignmentKind::Expect)
|
matches!(self, AssignmentKind::Expect)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn location_offset(&self) -> usize {
|
||||||
|
match self {
|
||||||
|
AssignmentKind::Let => 3,
|
||||||
|
AssignmentKind::Expect => 6,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type MultiPattern<PatternConstructor, Type> = Vec<Pattern<PatternConstructor, Type>>;
|
pub type MultiPattern<PatternConstructor, Type> = Vec<Pattern<PatternConstructor, Type>>;
|
||||||
|
|
|
@ -906,7 +906,7 @@ impl<'a, 'b> ExprTyper<'a, 'b> {
|
||||||
.push(Warning::SingleConstructorExpect {
|
.push(Warning::SingleConstructorExpect {
|
||||||
location: Span {
|
location: Span {
|
||||||
start: location.start,
|
start: location.start,
|
||||||
end: location.start + 6,
|
end: kind.location_offset(),
|
||||||
},
|
},
|
||||||
pattern_location: dbg!(untyped_pattern.location()),
|
pattern_location: dbg!(untyped_pattern.location()),
|
||||||
value_location: dbg!(untyped_value.location()),
|
value_location: dbg!(untyped_value.location()),
|
||||||
|
|
|
@ -20,6 +20,8 @@ use super::{
|
||||||
TypeInfo, ValueConstructor, ValueConstructorVariant,
|
TypeInfo, ValueConstructor, ValueConstructorVariant,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const PUB_OFFSET: usize = 3;
|
||||||
|
|
||||||
impl UntypedModule {
|
impl UntypedModule {
|
||||||
pub fn infer(
|
pub fn infer(
|
||||||
mut self,
|
mut self,
|
||||||
|
@ -162,7 +164,7 @@ fn infer_definition(
|
||||||
environment.warnings.push(Warning::PubInValidatorModule {
|
environment.warnings.push(Warning::PubInValidatorModule {
|
||||||
location: Span {
|
location: Span {
|
||||||
start: location.start,
|
start: location.start,
|
||||||
end: location.start + 3,
|
end: location.start + PUB_OFFSET,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -270,7 +272,7 @@ fn infer_definition(
|
||||||
environment.warnings.push(Warning::PubInValidatorModule {
|
environment.warnings.push(Warning::PubInValidatorModule {
|
||||||
location: Span {
|
location: Span {
|
||||||
start: location.start,
|
start: location.start,
|
||||||
end: location.start + 3,
|
end: location.start + PUB_OFFSET,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -306,7 +308,7 @@ fn infer_definition(
|
||||||
environment.warnings.push(Warning::PubInValidatorModule {
|
environment.warnings.push(Warning::PubInValidatorModule {
|
||||||
location: Span {
|
location: Span {
|
||||||
start: location.start,
|
start: location.start,
|
||||||
end: location.start + 3,
|
end: location.start + PUB_OFFSET,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -449,7 +451,7 @@ fn infer_definition(
|
||||||
environment.warnings.push(Warning::PubInValidatorModule {
|
environment.warnings.push(Warning::PubInValidatorModule {
|
||||||
location: Span {
|
location: Span {
|
||||||
start: location.start,
|
start: location.start,
|
||||||
end: location.start + 3,
|
end: location.start + PUB_OFFSET,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue