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
'exception Exc of (string * string)' and 'exception Exc of string * string' not necessarily the same #4182
Comments
Comment author: Colas
|
Comment author: @garrigue exception E of string * string and exception E of (string * string) have different internal representations, so they are incompatible. |
Comment author: cookedm Responding to Colas: Responding to garrigue: The type expression ( typexpr ) denotes the same type as typexpr I thought that was pretty clear :-) The other problem is that the output produced by ocaml is the same for both type t1 = E1 of string * string;;type t1 = E1 of string * string type t2 = E2 of (string * string);;type t2 = E2 of (string * string) E1 ("a", "b");;
E2 ("a", "b");;
so the pretty-printed version of the two values is identical. Either:
|
Comment author: @oandrieu cookedm: there is a difference between a constructor with one tuple argument (declared by "E of (string * string)" and a constructor with multiple arguments "E of string * string". The revised syntax of camlp4 makes this distinction way more clear by using a different keyword for the multiple arguments case: But I'm not sure where this is documented in the reference manual. Section 6.8.1, "Type definitions" says: "The constructor declaration constr-name of typexpr declares the name constr-name as a non-constant constructor, whose argument has type typexpr." It doesn't explain anything about constructors with multiple arguments. |
Comment author: @damiendoligez
In fact, it's a bug in the documentation. typexpr and (typexpr) are indeed equivalent, The documentation will be fixed in 3.10.0. |
Original bug ID: 4182
Reporter: cookedm
Status: closed (set by @damiendoligez on 2006-12-18T13:59:09Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.09.3
Fixed in version: 3.10+dev
Category: documentation
Bug description
If you have in your .mli file this
exception Exc of (string * string)
and in your .ml file this
exception Exc of string * string
then ocamlc will complain that
Exception declarations do not match:
exception Exc of string * string
is not included in
exception Exc of (string * string)
Note that this problem doesn't occur for type definitions.
Hardly a major bug, but it is surprising, as typexpr and (typexpr) should be equivalent.
Additional information
$ ocamlc -config
version: 3.09.3
standard_library_default: /opt/godi/lib/ocaml/std-lib
standard_library: /opt/godi/lib/ocaml/std-lib
standard_runtime: /opt/godi/bin/ocamlrun
ccomp_type: cc
bytecomp_c_compiler: gcc -fno-defer-pop -no-cpp-precomp -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
bytecomp_c_linker: gcc -L/opt/godi/lib
bytecomp_c_libraries: -lcurses -lpthread
native_c_compiler: gcc -Wall -D_FILE_OFFSET_BITS=64 -D_REENTRANT
native_c_linker: gcc -L/opt/godi/lib
native_c_libraries:
native_partial_linker: ld -r
ranlib: ranlib
cc_profile: -pg
architecture: i386
model: default
system: macosx
ext_obj: .o
ext_asm: .s
ext_lib: .a
ext_dll: .so
os_type: Unix
default_executable_name: a.out
systhread_supported: true
The text was updated successfully, but these errors were encountered: