You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 6056 Reporter: elnatan Assigned to:@garrigue Status: closed (set by @xavierleroy on 2015-12-11T18:20:02Z) Resolution: fixed Priority: normal Severity: minor Version: 4.00.1 Fixed in version: 4.01.0+dev Category: typing Related to:#6057 Monitored by:@gasche
Bug description
In the following two examples, using an 'if' statement allows the function to be generalized, but using 'match' prevents it.
let using_if b =
let f =
if b
then fun x -> x
else fun x -> x
in
f 0,f
;;
(* val using_if : bool -> int * ('a -> 'a) = *)
let using_match b =
let f =
match b with
| true -> fun x -> x
| false -> fun x -> x
in
f 0,f
;;
(* val using_match : bool -> int * (int -> int) = *)
Additional information
A colleague of mine suggests that this is due to the fact that 'match' statements are never considered to be nonexpansive.
The text was updated successfully, but these errors were encountered:
Actually, this is wrong: in "match e with p -> ...", e is generalized.
What is not generalized is the result of the match expression.
As you write, match expressions are never generalized,
whereas let expressions are generalized if subexpressions are non expansive.
So this should probably be done the same way.
Note that lazy patterns may cause side-effects, but this is already handled
by the typing of lazy values (i.e. a lazy value is not generalizable if forcing it
would cause side-effects)
Original bug ID: 6056
Reporter: elnatan
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:20:02Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.1
Fixed in version: 4.01.0+dev
Category: typing
Related to: #6057
Monitored by: @gasche
Bug description
In the following two examples, using an 'if' statement allows the function to be generalized, but using 'match' prevents it.
let using_if b =
let f =
if b
then fun x -> x
else fun x -> x
in
f 0,f
;;
(* val using_if : bool -> int * ('a -> 'a) = *)
let using_match b =
let f =
match b with
| true -> fun x -> x
| false -> fun x -> x
in
f 0,f
;;
(* val using_match : bool -> int * (int -> int) = *)
Additional information
A colleague of mine suggests that this is due to the fact that 'match' statements are never considered to be nonexpansive.
The text was updated successfully, but these errors were encountered: