Original bug ID: 6738
Reporter: oleg
Assigned to: @yallop
Status: resolved (set by @yallop on 2017-09-25T14:19:04Z)
Resolution: fixed
Priority: low
Severity: minor
Version: 4.02.1
Target version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Tags: patch
Related to: #4989 #6939 #7215 #7231 #7429
Monitored by: @gasche @glondu
Bug description
There are two restrictions on let rec: patterns must be simple
variable patterns (either just 'var' or '_ as var') and the variable
bound by let rec must appear under lambda, lazy or constructor.
These conditions are checked very late (in bytecomp/transcore.ml),
after type checking. But these are syntactic conditions; in
particular, the first condition can be checked during the parsing.
Minimal suggestion: check the first condition at parsing and
the second at type checking. So, a code that type checks should
produce no further compilation errors. Extended suggestion: since
let rec patterns are so restricted (and since the processing of patterns
becomes more involved with the addition of GADTs), separate
Pexp_let/Texp_let into Pexp_let and Pexp_letrec (ditto for Texp).
Type checking will become more orthogonal since in type checking Pexp_letrec
we don't need to care about GADTs, the exhaustiveness check and
the type propagation from expression to patterns.
Original bug ID: 6738
Reporter: oleg
Assigned to: @yallop
Status: resolved (set by @yallop on 2017-09-25T14:19:04Z)
Resolution: fixed
Priority: low
Severity: minor
Version: 4.02.1
Target version: 4.06.0 +dev/beta1/beta2/rc1
Category: typing
Tags: patch
Related to: #4989 #6939 #7215 #7231 #7429
Monitored by: @gasche @glondu
Bug description
There are two restrictions on let rec: patterns must be simple
variable patterns (either just 'var' or '_ as var') and the variable
bound by let rec must appear under lambda, lazy or constructor.
These conditions are checked very late (in bytecomp/transcore.ml),
after type checking. But these are syntactic conditions; in
particular, the first condition can be checked during the parsing.
Minimal suggestion: check the first condition at parsing and
the second at type checking. So, a code that type checks should
produce no further compilation errors. Extended suggestion: since
let rec patterns are so restricted (and since the processing of patterns
becomes more involved with the addition of GADTs), separate
Pexp_let/Texp_let into Pexp_let and Pexp_letrec (ditto for Texp).
Type checking will become more orthogonal since in type checking Pexp_letrec
we don't need to care about GADTs, the exhaustiveness check and
the type propagation from expression to patterns.