diff --git a/src/destruct.rs b/src/destruct.rs index c5af0d2e..eebe808b 100644 --- a/src/destruct.rs +++ b/src/destruct.rs @@ -121,7 +121,7 @@ impl Match { // - missing field on the `id` Match::Assign(id, m, (_, d @ Destruct::Record { .. })) => { let label @ Label { span, .. } = d.label(); - let span = RawSpan::fuse(id.pos().unwrap(), span).unwrap(); + let span = RawSpan::fuse(id.pos.unwrap(), span).unwrap(); let label = Label { span, ..label }; ( id, diff --git a/src/eval/merge.rs b/src/eval/merge.rs index 4076867c..16422ddd 100644 --- a/src/eval/merge.rs +++ b/src/eval/merge.rs @@ -475,7 +475,7 @@ fn cross_apply_contracts<'a>( let ty_closure = ctr.types.clone().closurize(&mut env1_local, env2.clone()); mk_term::assume(ty_closure, ctr.label.clone(), acc) .map_err(|crate::types::UnboundTypeVariableError(id)| { - let pos = id.pos(); + let pos = id.pos; EvalError::UnboundIdentifier(id, pos) }) .map(|rt| rt.with_pos(pos)) diff --git a/src/identifier.rs b/src/identifier.rs index cc98f4b1..a822343d 100644 --- a/src/identifier.rs +++ b/src/identifier.rs @@ -12,7 +12,7 @@ static INTERNER: Lazy = Lazy::new(interner::Interner::new); #[serde(into = "String", from = "String")] pub struct Ident { symbol: interner::Symbol, - pos: TermPos, + pub pos: TermPos, generated: bool, } @@ -33,10 +33,6 @@ impl Ident { pub fn label(&self) -> &str { INTERNER.lookup(self.symbol) } - - pub fn pos(&self) -> TermPos { - self.pos - } } /// Special character used for generating fresh identifiers. It must be syntactically impossible to diff --git a/src/parser/grammar.lalrpop b/src/parser/grammar.lalrpop index c73b27d4..43198560 100644 --- a/src/parser/grammar.lalrpop +++ b/src/parser/grammar.lalrpop @@ -400,7 +400,7 @@ Match: Match = { _ => MetaValue { contracts: vec![Contract{ types: Types(AbsType::Dyn().into()), - label: Label{span: left.pos().unwrap(), ..Default::default()}, + label: Label{span: left.pos.unwrap(), ..Default::default()}, }], ..Default::default() }, @@ -415,7 +415,7 @@ Match: Match = { _ => MetaValue { contracts: vec![Contract{ types: Types(AbsType::Dyn().into()), - label: Label{span: id.pos().unwrap(), ..Default::default()}, + label: Label{span: id.pos.unwrap(), ..Default::default()}, }], ..Default::default() }, diff --git a/src/parser/uniterm.rs b/src/parser/uniterm.rs index 235402c3..c81b0daa 100644 --- a/src/parser/uniterm.rs +++ b/src/parser/uniterm.rs @@ -91,7 +91,7 @@ impl TryFrom for RichTerm { UniTermNode::Types(ty) => { ty.contract().map_err(|UnboundTypeVariableError(id)| { // We unwrap the position of the identifier, which must be set at this stage of parsing - let pos = id.pos(); + let pos = id.pos; ParseError::UnboundTypeVariables(vec![id], pos.unwrap()) })? } @@ -187,7 +187,7 @@ impl UniRecord { let span = path .into_iter() .map(|path_elem| match path_elem { - FieldPathElem::Ident(id) => id.pos().into_opt(), + FieldPathElem::Ident(id) => id.pos.into_opt(), FieldPathElem::Expr(rt) => rt.pos.into_opt(), }) .reduce(|acc, pos| { @@ -221,7 +221,7 @@ impl UniRecord { _ => { // Position of identifiers must always be set at this stage // (parsing) - let span_id = id.pos().unwrap(); + let span_id = id.pos.unwrap(); let term_pos = rt.pos.into_opt().unwrap_or(span_id); Err(InvalidRecordTypeError(TermPos::Original( RawSpan::fuse(span_id, term_pos).unwrap(), @@ -362,7 +362,7 @@ pub fn fix_type_vars(ty: &mut Types) { AbsType::Var(ref mut id) => { if !bound_vars.contains(id) { let id = *id; - let pos = id.pos(); + let pos = id.pos; ty.0 = AbsType::Flat(RichTerm::new(Term::Var(id), pos)); } } diff --git a/src/types.rs b/src/types.rs index bd6e0a46..42d53daa 100644 --- a/src/types.rs +++ b/src/types.rs @@ -164,14 +164,14 @@ pub struct UnboundTypeVariableError(pub Ident); impl From for TypecheckError { fn from(err: UnboundTypeVariableError) -> Self { - let pos = err.0.pos(); + let pos = err.0.pos; TypecheckError::UnboundTypeVariable(err.0, pos) } } impl From for ParseError { fn from(err: UnboundTypeVariableError) -> Self { - let pos = err.0.pos(); + let pos = err.0.pos; ParseError::UnboundTypeVariables(vec![err.0], pos.unwrap()) } }