Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006417OCaml~DO NOT USE (was: OCaml general)public2014-05-13 12:252015-12-11 19:27
ReporterNick Chapman 
Assigned Togarrigue 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.02.0+dev 
Summary0006417: sprintf broken when local module named Pervasives is in scope
The following ml is rejected by the latest trunk 4.02
Having a local module named Pervasives in scope, breaks a following sprintf.

module Pervasives = struct end
let _:string = Printf.sprintf "%d" 123

File "", line 2, characters 30-34:
Error: This expression has type string but an expression was expected of type
         ('a -> 'b, unit, string) format =
           ('a -> 'b, unit, string, string, string, string)
           CamlinternalFormatBasics.fmt * string
Steps To Reproduce4.02 trunk
commit c82c004286dae541583a45cff042624b3770b7a0
TagsNo tags attached.
Attached Filespatch file icon format-gadts-pervasives-v1.patch [^] (5,169 bytes) 2014-05-25 12:38 [Show Content]
patch file icon format-gadts-pervasives-v2.patch [^] (7,197 bytes) 2014-05-25 18:58 [Show Content]
diff file icon formatBasics.diff [^] (110,759 bytes) 2014-05-27 08:08 [Show Content]

- Relationships

-  Notes
gasche (developer)
2014-05-13 16:46

I'm afraid this is a case that hasn't been considered in the format work. I'll try to think about this.

Could you tell more about your use-case for rebinding Pervasives?
Nick Chapman (reporter)
2014-05-14 08:49

The name "Pervasives" is being used as the name for a non top-level module. It is not intended in any way to rebind the real Pervasives.

This was in code which already existed in our code base; but it is not a widely used idiom, and so should be only a small effort to choose a different name.

However, it does seem rather surprising that format strings would compile to reference the definition of Pervasives which is dynamically in scope.
gasche (developer)
2014-05-25 12:39

I have a first working patch (uploaded above), but it may still need a bit of polish. A full fix is hopefully coming soon.
garrigue (manager)
2014-05-27 08:13

Fixed by applying formatBasics.diff, committed in 4.02 at revision 14921.

This solves the problem by turning CamlinternalFormatBasics into an independent compilation unit, which is referred to by Pervasives, but does not require it.

- Issue History
Date Modified Username Field Change
2014-05-13 12:25 Nick Chapman New Issue
2014-05-13 16:43 gasche Assigned To => gasche
2014-05-13 16:43 gasche Status new => assigned
2014-05-13 16:46 gasche Note Added: 0011440
2014-05-14 08:49 Nick Chapman Note Added: 0011452
2014-05-25 12:38 gasche File Added: format-gadts-pervasives-v1.patch
2014-05-25 12:39 gasche Note Added: 0011564
2014-05-25 18:58 gasche File Added: format-gadts-pervasives-v2.patch
2014-05-27 08:08 garrigue File Added: formatBasics.diff
2014-05-27 08:13 garrigue Note Added: 0011574
2014-05-27 08:13 garrigue Status assigned => resolved
2014-05-27 08:13 garrigue Fixed in Version => 4.02.0+dev
2014-05-27 08:13 garrigue Resolution open => fixed
2014-05-27 08:13 garrigue Assigned To gasche => garrigue
2015-12-11 19:27 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker