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

Incorrect ordinal number in error message #5571

Closed
vicuna opened this issue Apr 2, 2012 · 4 comments
Closed

Incorrect ordinal number in error message #5571

vicuna opened this issue Apr 2, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

@vicuna vicuna commented Apr 2, 2012

Original bug ID: 5571
Reporter: jfc
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:20:54Z)
Resolution: fixed
Priority: low
Severity: trivial
Version: 3.12.1
Target version: 4.01.0+dev
Fixed in version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

ocamlc forms some ordinal numbers incorrectly in error messages.

The attached program causes an error message:

   Their 21th fields have different names, X and C.

"21th" should be "21st".

This replacement nth seems to do the right thing.

let nth n =
if n = 1 then "first" else
let n_100 = n mod 100 and n_10 = n mod 10 in
if n_10 = 1 && n_100 <> 11 then (string_of_int n) ^ "st" else
if n_10 = 2 && n_100 <> 12 then (string_of_int n) ^ "nd" else
if n_10 = 3 && n_100 <> 13 then (string_of_int n) ^ "rd" else
string_of_int n ^ "th"

File attachments

@vicuna
Copy link
Author

@vicuna vicuna commented Apr 3, 2012

Comment author: @gasche

Just reading the PR title, I first thought it was an April joke, and
found it funny. "?^? not printed correctly".

@vicuna
Copy link
Author

@vicuna vicuna commented Apr 3, 2012

Comment author: @xavierleroy

I'd suggest avoiding adding code for this issue and change the message instead. "Fields number 21 have..."

@vicuna
Copy link
Author

@vicuna vicuna commented Sep 6, 2012

Comment author: @damiendoligez

For the record, I am very much in favor of Xavier's solution. Our core business is not natural language processing.

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 9, 2013

Comment author: @alainfrisch

Implemented Xavier's suggestion (13877 on trunk, 13878 on 4.01).

@vicuna vicuna closed this Dec 11, 2015
@vicuna vicuna added this to the 4.01.0 milestone Mar 14, 2019
@vicuna vicuna added the bug label Mar 20, 2019
dra27 pushed a commit to dra27/ocaml that referenced this issue Feb 27, 2021
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