Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type checker could be better at recognising format strings #6708

Closed
vicuna opened this issue Dec 12, 2014 · 2 comments
Closed

type checker could be better at recognising format strings #6708

vicuna opened this issue Dec 12, 2014 · 2 comments

Comments

@vicuna
Copy link

vicuna commented Dec 12, 2014

Original bug ID: 6708
Reporter: MarkJosephs
Status: closed (set by @alainfrisch on 2014-12-12T14:26:45Z)
Resolution: not a bug
Priority: normal
Severity: minor
Category: typing

Bug description

I would have expected Printf.sprintf to always try to perform the "format hack" on strings, but found that I had to help it by inserting "format_of_string".

Steps to reproduce

let selective_print singular = Printf.sprintf (if singular then "%s is fun" else "%s are fun");;

Error: This expression has type string but an expression was expected of type
('a, unit, string) format =
('a, unit, string, string, string, string) format6

let selective_print singular = Printf.sprintf (if singular then format_of_string "%s is fun" else format_of_string "%s are fun");;

val selective_print : bool -> string -> string =

@vicuna
Copy link
Author

vicuna commented Dec 12, 2014

Comment author: @lpw25

What version of OCaml? I'm pretty sure this has worked since forward propagation was added in version 4.00.0.

@vicuna
Copy link
Author

vicuna commented Dec 12, 2014

Comment author: MarkJosephs

I am using version 3.12.1. Thank you for pointing out that it has been fixed in version 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant