mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Temporarily disable List.get in favor of getUnsafe
This commit is contained in:
parent
52a3e0afb5
commit
1bee16decd
6 changed files with 141 additions and 142 deletions
|
@ -371,7 +371,20 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
|
||||
// List module
|
||||
|
||||
// get : List elem, Int -> Result elem [ IndexOutOfBounds ]*
|
||||
// get : List elem, Int -> Result elem [ OutOfBounds ]*
|
||||
let index_out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::LIST_GET,
|
||||
SolvedType::Func(
|
||||
vec![list_type(flex(TVAR1)), int_type()],
|
||||
Box::new(result_type(flex(TVAR1), index_out_of_bounds)),
|
||||
),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::LIST_GET_UNSAFE,
|
||||
SolvedType::Func(
|
||||
|
|
|
@ -450,7 +450,20 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
unique_function(vec![list_type(UVAR1, TVAR1)], int_type(UVAR2)),
|
||||
);
|
||||
|
||||
// #getUnsafe : List elem, Int -> elem
|
||||
// get : List a, Int -> Result a [ OutOfBounds ]*
|
||||
let index_out_of_bounds = SolvedType::TagUnion(
|
||||
vec![(TagName::Global("OutOfBounds".into()), vec![])],
|
||||
Box::new(SolvedType::Wildcard),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::LIST_GET,
|
||||
unique_function(
|
||||
vec![list_type(UVAR1, TVAR1), int_type(UVAR2)],
|
||||
result_type(UVAR3, flex(TVAR1), lift(UVAR4, index_out_of_bounds)),
|
||||
),
|
||||
);
|
||||
|
||||
add_type(
|
||||
Symbol::LIST_GET_UNSAFE,
|
||||
unique_function(vec![list_type(UVAR1, TVAR1), int_type(UVAR2)], flex(TVAR1)),
|
||||
|
@ -934,6 +947,17 @@ fn num_type(u: VarId, a: VarId) -> SolvedType {
|
|||
)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn result_type(u: VarId, a: SolvedType, e: SolvedType) -> SolvedType {
|
||||
SolvedType::Apply(
|
||||
Symbol::ATTR_ATTR,
|
||||
vec![
|
||||
flex(u),
|
||||
SolvedType::Apply(Symbol::RESULT_RESULT, vec![a, e]),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn list_type(u: VarId, a: VarId) -> SolvedType {
|
||||
SolvedType::Apply(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue