Skip to content

Commit

Permalink
Fix missing position panic, remove unused function
Browse files Browse the repository at this point in the history
  • Loading branch information
yannham committed Nov 25, 2024
1 parent 1f8fb29 commit 1274e47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
8 changes: 6 additions & 2 deletions core/src/parser/uniterm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ where
// For nodes such as `Type` or `Record`, the following implementation has to choose between two
// positions to use: the one of the wrapping `UniTerm`, and the one stored inside the `RichTerm` or
// the `Type`. This implementation assumes that the latest set is the one of `UniTerm`, which is
// the single source of truth.
// the single source of truth. In fact, it happens that only the outermost uniterm position is set
// while the innermost is still `TermPos::None`.
impl<'ast> TryConvert<'ast, UniTerm<'ast>> for Type<'ast> {
type Error = ParseError;

Expand All @@ -123,7 +124,10 @@ impl<'ast> TryConvert<'ast, UniTerm<'ast>> for Type<'ast> {
return Err(ParseError::InvalidContract(ut.pos.unwrap()));
}

TypeF::Contract(alloc.ast(ast))
TypeF::Contract(alloc.ast(Ast {
node: ast.node,
pos,
}))
}
};

Expand Down
15 changes: 4 additions & 11 deletions core/src/parser/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ impl EtaExpand for ExtendedInfixOp {
primop::PrimOp::Eq,
builder::var(fst_arg),
builder::var(snd_arg),
),
),
)
.with_pos(pos),
)
.with_pos(pos),
)
.node
}
Expand Down Expand Up @@ -360,15 +362,6 @@ pub fn mk_label(typ: Type, src_id: FileId, l: usize, r: usize) -> Label {
}
}

/// Same as `mk_span`, but for merge labels. The kind is set to the default one
/// (`MergeKind::Standard`).
pub fn mk_merge_label(src_id: FileId, l: usize, r: usize) -> MergeLabel {
MergeLabel {
span: mk_span(src_id, l, r),
kind: Default::default(),
}
}

/// Checks that there are no duplicate bindings in a let block (when bindins are simple, that is
/// they aren't pattern), and builds the corresponding let block node if the check passes.
pub fn mk_let<'ast>(
Expand Down

0 comments on commit 1274e47

Please sign in to comment.