Module params are not extensible

This commit is contained in:
Agus Zubiaga 2024-07-01 15:37:05 -03:00
parent 5ec4b042bb
commit f0fe0a3ea6
No known key found for this signature in database
3 changed files with 51 additions and 3 deletions

View file

@ -6,6 +6,7 @@ use roc_can::expected::{Expected, PExpected};
use roc_can::expr::{AnnotatedMark, Declarations};
use roc_can::pattern::Pattern;
use roc_collections::MutMap;
use roc_error_macros::internal_error;
use roc_module::symbol::{ModuleId, Symbol};
use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
@ -63,6 +64,21 @@ fn constrain_params(
let mut state = PatternState::default();
let closed_con = match loc_pattern.value {
Pattern::RecordDestructure {
whole_var: _,
ext_var,
destructs: _,
} => {
// Disallow record extension for module params
let empty_rec = constraints.push_type(types, Types::EMPTY_RECORD);
constraints.store(empty_rec, ext_var, file!(), line!())
}
_ => internal_error!("Only record destructures are allowed in module params. This should've been caught earlier."),
};
state.constraints.push(closed_con);
constrain_pattern(
types,
constraints,