Skip to content

Commit d89f5ee

Browse files
committed
Add Str.try_from_str
1 parent fecdac4 commit d89f5ee

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/build/roc/Builtin.roc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ Builtin :: [].{
44

55
contains : Str, Str -> Bool
66
contains = |_str, _other| True
7+
8+
try_from_str : Str -> Try(Str, [InvalidStr(Str)])
9+
try_from_str = |self| Try.Ok(self)
710
}
811

912
List(_item) :: [ProvidedByCompiler].{

src/check/Check.zig

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4763,17 +4763,6 @@ fn checkDeferredStaticDispatchConstraints(self: *Self, env: *Env) std.mem.Alloca
47634763
// Iterate over the constraints
47644764
const constraints = self.types.sliceStaticDispatchConstraints(deferred_constraint.constraints);
47654765
for (constraints) |constraint| {
4766-
// For try_from_str constraints, skip validation if the type is Str
4767-
// Str is the default/identity type for string literals and doesn't need try_from_str
4768-
if (constraint.origin == .try_from_str) {
4769-
if (std.mem.eql(u8, type_name_bytes, "Str") or
4770-
std.mem.eql(u8, type_name_bytes, "Builtin.Str"))
4771-
{
4772-
// Str is the default type - no validation needed
4773-
continue;
4774-
}
4775-
}
4776-
47774766
// Extract the function and return type from the constraint
47784767
const resolved_constraint = self.types.resolveVar(constraint.fn_var);
47794768
const mb_resolved_func = resolved_constraint.desc.content.unwrapFunc();

0 commit comments

Comments
 (0)