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

wrong error message (parser seems to interpret many lines as one line) (3.10.2 and 3.10.0) #4659

Closed
vicuna opened this issue Nov 29, 2008 · 3 comments
Assignees
Labels
Milestone

Comments

@vicuna
Copy link

vicuna commented Nov 29, 2008

Original bug ID: 4659
Reporter: oliver
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:07:27Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.2
Target version: 4.01.0+dev
Category: ~DO NOT USE (was: OCaml general)
Related to: #4598 #5070
Monitored by: oliver @Chris00

Bug description

I get the following error message:

===============
oliver@siouxsie:/Desktop/Overwrite_file$ ocamlc unix.cma buggy.ml
File "buggy.ml", line 20, characters 4-321:
Warning F: this function application is partial,
maybe some arguments are missing.
oliver@siouxsie:
/Desktop/Overwrite_file$

Line 20 has length of 41 bytes!

The bug of my program is located in line 29,
where I used Printf.printf, expecting an arg, but do not provide it.

This means: the partial application is correctly mentioned by the compiler,
but the line and char-in-line is reported wrongly.

The problem occurs with ocamlc, ocamlopt and ocaml.

Additional information

For first overview, I provide the result of "$ nl -ba buggy.ml",
but I will attach the file for your convenience:

 1	
 2	let mb x = x * 1024 * 1024
 3	
 4	open Unix
 5	
 6	let _ =
 7	  let filename = Sys.argv.(1) in
 8	  let filesize = (stat filename).st_size in
 9	  Printf.printf "%d\n" filesize;
10	
11	  let restbytes = ref filesize in
12	
13	  let strlen = mb 100 in
14	  let string = String.make strlen ' ' in
15	  let writesize = ref strlen in
16	
17	  let fd = openfile filename [O_RDWR] 0o640 in
18	  while !restbytes > 0
19	  do
20	    writesize := (min !restbytes strlen);
21	
22	Printf.printf "restbytes: %d, writesize: %d\n" !restbytes !writesize;
23	flush Pervasives.stdout;
24	
25	    let num = write fd string 0 !writesize in
26	    restbytes := max 0 (!restbytes - num );
27	
28	Printf.printf "(just written: %d)\n" num;
29	Printf.printf "restbytes: %d\n-----------\n" (* HERE IS THE BUG! *)
30	
31	  done;
32	  close fd
33	
34	
35

File attachments

@vicuna
Copy link
Author

vicuna commented Dec 3, 2008

Comment author: @damiendoligez

In fact, the reported character range is correct (it goes from the 'w' in line 20 to the last quote in line 29).
What is wrong with this error message is that it reports the whole sequence as the partially-applied function. It should report only its last subexpression (i.e. line 29).

@vicuna
Copy link
Author

vicuna commented Dec 3, 2008

Comment author: @damiendoligez

Maybe we should also switch to the new way of reporting character ranges used by Emacs.

@vicuna
Copy link
Author

vicuna commented Jul 27, 2012

Comment author: @alainfrisch

It should report only its last subexpression (i.e. line 29).

Fixed by #5697.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants