Skip to content

Resolving record fields using all specified fields #5525

@vicuna

Description

@vicuna

Original bug ID: 5525
Reporter: @alainfrisch
Assigned to: @garrigue
Status: closed (set by @xavierleroy on 2015-12-11T18:25:43Z)
Resolution: fixed
Priority: normal
Severity: feature
Fixed in version: 4.01.0+dev
Category: typing
Related to: #4172 #5528
Child of: #5759
Monitored by: @gasche tgazagna @diml pveber @ygrek @hcarty

Bug description

With punning on record labels, programmers have a stronger incentive to use nice short names for record labels and avoid the disambiguation-by-prefixing technique.

The following proposal would make it possible, in some cases, to work with several record types that share some field names: when typing a record literal {[e0 with] l1 = e1; ... ; ln = en} or a record pattern {l1 = p1; ...; ln = pn}, the type-checker would search the current typing environment for a record type declaration that includes all the fields {l1, ..., ln}.

This cannot break existing well-typed code.

We have been using this modified resolution at LexiFi for a few years now. The patch is tiny. I can adapt it to the OCaml trunk if the proposal is accepted.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions