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

Error messages for 1-tuples are confusing #6388

vicuna opened this issue May 1, 2014 · 2 comments


None yet
2 participants
Copy link

commented May 1, 2014

Original bug ID: 6388
Reporter: @whitequark
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:27:53Z)
Resolution: fixed
Priority: normal
Severity: minor
Fixed in version: 4.02.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #6424

Bug description

If I construct an 1-tuple directly via AST, e.g. with Ast_helper.Exp.tuple [a], the error message from typechecker is as follows:

Error: This expression has type int but an expression was expected of type int

Also, the pretty-printer prints it as an expression, which doesn't help.

I think the Pprintast should be extended to print 1-tuples (and perhaps 0-tuples?) in a special way; if I did not know exactly what the bug were, I would have spent hours figuring it out.


This comment has been minimized.

Copy link

commented May 2, 2014

Comment author: @alainfrisch

Instead of adapting the printer, I think it would make more sense to check in the type-checker the invariants which are normally enforced by the parser, but could be broken if one uses -pp/-ppx processors.


This comment has been minimized.

Copy link

commented Jun 3, 2014

Comment author: @alainfrisch

Commit 14949 in 4.02 checks that tuples have at least 2 elements. (Please shout if you have a legitimate use of "unary tuples" in generated code.) The same commit adds some more invariant checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.