Skip to content

Commit

Permalink
Fix number type constraint to allow types with methods. (#3637)
Browse files Browse the repository at this point in the history
  • Loading branch information
toots authored Jan 15, 2024
1 parent 008f275 commit 2f7fb67
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lang/type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ let num_constr =
constr_descr = "a number type";
univ_descr = None;
satisfied =
(fun ~subtype:_ ~satisfies:_ b ->
(fun ~subtype:_ ~satisfies b ->
let b = demeth b in
match b.descr with
| Var _ -> satisfies b
| Custom { typ = Ground.Never.Type }
| Custom { typ = Ground.Int.Type }
| Custom { typ = Ground.Float.Type } ->
Expand Down
10 changes: 10 additions & 0 deletions tests/language/number.liq
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ def f() =
test.equals(round(0.), 0.)
test.equals(round(infinity), infinity)
test.equals(round(nan), nan)

def f(x) =
print(
"x.foo is: " ^
x.foo
)
x + 1
end
test.equals(f(1.{foo="gni"}), 2)

test.pass()
end

Expand Down

0 comments on commit 2f7fb67

Please sign in to comment.