mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Add types for Str.startsWith
This commit is contained in:
parent
9e1836dde0
commit
b82baf55e7
3 changed files with 24 additions and 0 deletions
|
@ -505,6 +505,12 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
top_level_function(vec![str_type()], Box::new(bool_type())),
|
||||
);
|
||||
|
||||
// startsWith : Str, Str -> Bool
|
||||
add_type(
|
||||
Symbol::STR_STARTS_WITH,
|
||||
SolvedType::Func(vec![str_type(), str_type()], Box::new(bool_type())),
|
||||
);
|
||||
|
||||
// List module
|
||||
|
||||
// get : List elem, Int -> Result elem [ OutOfBounds ]*
|
||||
|
|
|
@ -1134,6 +1134,12 @@ pub fn types() -> MutMap<Symbol, (SolvedType, Region)> {
|
|||
unique_function(vec![str_type(star1), str_type(star2)], str_type(star3))
|
||||
});
|
||||
|
||||
// Str.startsWith : Attr * Str, Attr * Str -> Attr * Bool
|
||||
add_type(Symbol::STR_STARTS_WITH, {
|
||||
let_tvars! { star1, star2, star3 };
|
||||
unique_function(vec![str_type(star1), str_type(star2)], bool_type(star3))
|
||||
});
|
||||
|
||||
// Result module
|
||||
|
||||
// map : Attr * (Result (Attr a e))
|
||||
|
|
|
@ -192,6 +192,18 @@ mod solve_expr {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn string_starts_with() {
|
||||
infer_eq_without_problem(
|
||||
indoc!(
|
||||
r#"
|
||||
Str.startsWith
|
||||
"#
|
||||
),
|
||||
"Str, Str -> Bool",
|
||||
);
|
||||
}
|
||||
|
||||
// #[test]
|
||||
// fn block_string_literal() {
|
||||
// infer_eq(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue