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

Closed
vicuna opened this issue May 1, 2014 · 2 comments
Closed

Error messages for 1-tuples are confusing #6388

vicuna opened this issue May 1, 2014 · 2 comments
Assignees
Labels

Comments

@vicuna
Copy link

@vicuna vicuna 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.

@vicuna
Copy link
Author

@vicuna vicuna 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.

@vicuna
Copy link
Author

@vicuna vicuna 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.

@vicuna vicuna closed this Dec 11, 2015
@vicuna vicuna added the bug label Mar 20, 2019
avsm pushed a commit to avsm/ocaml that referenced this issue Jun 21, 2020
…ry tuples, empty record (exprs, types, pats) and empty variant types.

git-svn-id: http://caml.inria.fr/svn/ocaml/version/4.02@14949 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants