Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006303OCamlOCaml typingpublic2014-01-22 13:272014-01-23 03:00
Reporterfrisch 
Assigned Togarrigue 
PrioritynormalSeveritymajorReproducibilityhave not tried
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.02.0+dev 
Summary0006303: Types not inferred properly for fields on record overrides
DescriptionOn trunk, it seems that an expression {e with x = ...} does not propagate type constraints from x to the record type. The following code segfaults:

type 'a foo = {x: 'a; y: int}
let r = {{x = 0; y = 0} with x = 0}
let () = print_endline (r.x ^ "")

The type inferred for [r] is a polymorphic ['a foo], instead of [int foo].
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0010826)
frisch (developer)
2014-01-22 13:38
edited on: 2014-01-22 13:41

Introduced by commit 14166, and more precisely this change:

            let op =
              match opt_exp with
                None -> None
              | Some exp -> get_path exp.exp_type
            in
            newvar (), op


---->


            begin match opt_exp with
              None -> newvar (), None
            | Some exp ->
                match get_path exp.exp_type with
                  None -> newvar (), None
                | Some (_, p', _) as op ->
                    let decl = Env.find_type p' env in
                    begin_def ();
                    let ty =
                      newconstr p' (instance_list env decl.type_params) in
                    end_def ();
                    generalize ty;
                    ty, op
            end


Removing the call to [generalize] seems to solve the issue. Jacques: is it a correct fix?

(0010833)
garrigue (manager)
2014-01-23 03:00

Fixed in revision 14415.
In this case we should only generalize the structure: use generalize_structure rather than generalize.

- Issue History
Date Modified Username Field Change
2014-01-22 13:27 frisch New Issue
2014-01-22 13:38 frisch Note Added: 0010826
2014-01-22 13:41 frisch Note Edited: 0010826 View Revisions
2014-01-23 03:00 garrigue Note Added: 0010833
2014-01-23 03:00 garrigue Status new => resolved
2014-01-23 03:00 garrigue Fixed in Version => 4.02.0+dev
2014-01-23 03:00 garrigue Resolution open => fixed
2014-01-23 03:00 garrigue Assigned To => garrigue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker