From 2f7fb67a5474fa51e1cb4bb0b3970d8ee46b112e Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Mon, 15 Jan 2024 17:53:32 -0600 Subject: [PATCH] Fix number type constraint to allow types with methods. (#3637) --- src/lang/type.ml | 3 ++- tests/language/number.liq | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/lang/type.ml b/src/lang/type.ml index 4aa344cd33..691494d6c9 100644 --- a/src/lang/type.ml +++ b/src/lang/type.ml @@ -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 } -> diff --git a/tests/language/number.liq b/tests/language/number.liq index 3362bc4c7d..6910ad037a 100644 --- a/tests/language/number.liq +++ b/tests/language/number.liq @@ -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