Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006417OCamlOCaml generalpublic2014-05-13 12:252014-05-27 08:13
ReporterNick Chapman 
Assigned Togarrigue 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version4.02.0+dev 
Summary0006417: sprintf broken when local module named Pervasives is in scope
Description
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 "bad_sprintf.ml", 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
(0011440)
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?
(0011452)
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.
(0011564)
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.
(0011574)
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


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker