mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-23 03:52:27 +00:00
Move check_ext_var to utility module
This commit is contained in:
parent
0cc3eae2cb
commit
275391c065
3 changed files with 23 additions and 19 deletions
19
crates/compiler/derive_key/src/util.rs
Normal file
19
crates/compiler/derive_key/src/util.rs
Normal file
|
@ -0,0 +1,19 @@
|
|||
use roc_types::subs::{Content, Subs, Variable};
|
||||
|
||||
use crate::DeriveError;
|
||||
|
||||
pub(crate) fn check_empty_ext_var(
|
||||
subs: &Subs,
|
||||
ext_var: Variable,
|
||||
is_empty_ext: impl Fn(&Content) -> bool,
|
||||
) -> Result<(), DeriveError> {
|
||||
let ext_content = subs.get_content_without_compacting(ext_var);
|
||||
if is_empty_ext(ext_content) {
|
||||
Ok(())
|
||||
} else {
|
||||
match ext_content {
|
||||
Content::FlexVar(_) => Err(DeriveError::UnboundVar),
|
||||
_ => Err(DeriveError::Underivable),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue