Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000256OCamlOCaml generalpublic2001-01-05 23:302001-01-08 11:54
Reporteradministrator 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0000256: Warning: this expression should have type unit
DescriptionFull_Name: Damir Jamsek
Version: Ocaml 3.00
OS: Linux
Submission from: ss08.nc.us.ibm.com (32.97.136.238)


If you compile the following lines, the warning message only occurs for
the sequential composition in function foo, but not in function bar

comments?
thank you,
--damir

(* file: foobar.ml; Compile: ocamlc -c foobar.ml *)

let foo_tbl = ((Hashtbl.create 1013) : (int,int) Hashtbl.t)
let bar_tbl = Hashtbl.create 1013


let foo f = Hashtbl.find foo_tbl f; failwith "foo"
let bar b = Hashtbl.find bar_tbl b; failwith "bar"

(* function doo helps typing bar_tbl *)
let doo d = d + Hashtbl.find bar_tbl d

   

TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0002197)
administrator (administrator)
2001-01-08 12:55

> Full_Name: Damir Jamsek
> Version: Ocaml 3.00
> OS: Linux
> Submission from: ss08.nc.us.ibm.com (32.97.136.238)
>
>
> If you compile the following lines, the warning message only occurs for
> the sequential composition in function foo, but not in function bar
>
> comments?
> thank you,
> --damir
>
> (* file: foobar.ml; Compile: ocamlc -c foobar.ml *)
>
> let foo_tbl = ((Hashtbl.create 1013) : (int,int) Hashtbl.t)
> let bar_tbl = Hashtbl.create 1013
>
>
> let foo f = Hashtbl.find foo_tbl f; failwith "foo"
> let bar b = Hashtbl.find bar_tbl b; failwith "bar"
>
> (* function doo helps typing bar_tbl *)
> let doo d = d + Hashtbl.find bar_tbl d

The sequence warning is an approximation: when examining e1; e2, if
the compiler can prove that the type of the expression e1 cannot be
unit, it emits a warning. For instance, when defining foo the compiler
knows that Hashtbl.find would return an integer (due to the
explicitely declared type of foo_tbl), hence the warning. By contrast,
when defining bar the type instance of bar_tbl is still unknown and
thus the result type of the expression Hashtbl.find bar_tbl b is an
unknown type variable which could eventually be unified with unit
afterwards, hence the type checker cannot prove that this type cannot
be unit and it does not emit the sequence warning.

Best regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/ [^]



- Issue History
Date Modified Username Field Change
2005-11-18 10:13 administrator New Issue


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker