Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006604OCamllexing and parsingpublic2014-10-08 15:122017-10-04 11:07
Reporterrdicosmo 
Assigned Togasche 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version 
Target Version4.06.0 +dev/beta1/beta2/rc1Fixed in Version4.07.0+dev/beta2/rc1/rc2 
Summary0006604: Expressions like 3#0;; are ignored by the toplevel and the compiler
DescriptionThe very simple syntactically incorrect expression 3#0;; is simply ignored both by the toplevel and the compiler. On the other hand, 3#foo;; is handled properly
Steps To ReproduceJust type 3#0;; in any toplevel (tested 3.12 , 4.00, 4.01 and 4.02)

$ ocaml
        OCaml version 4.01.0

# 3#0;;
  
  ^CInterrupted.
# 3#foo;;
Error: This expression has type int
       It has no method foo


Or try to compile a file containing the single line

3#0;;

Additional InformationThe interpreter executed via js_of_ocaml (see try.ocamlpro.org, for example) does not exhibit this behaviour.

Welcome to TryOCaml (v. 4.01.0)

# 3#0;;
File "", line 1, characters 2-3:
Error: Syntax error
File "", line 1, characters 3-5:
Error: Syntax error
Tagsjunior_job
Attached Files

- Relationships

-  Notes
(0012326)
yallop (developer)
2014-10-08 16:01

The '#0' is a way of setting the line number for error messages; it's used in tools like ocamlyacc.

   $ cat lines1.ml
   let x = 2 + 3#0
    in x + "four"
   $ ocamlc lines1.ml
   File "lines1.ml", line 0, characters 8-14:
   Error: This expression has type string but an expression was expected of type
            int
   $ cat lines2.ml
   let x = 2 + 3
    in x + "four"
   $ ocamlc lines2.ml
   File "lines2.ml", line 2, characters 8-14:
   Error: This expression has type string but an expression was expected of type
            int
(0012327)
doligez (administrator)
2014-10-08 17:14

If possible, we should find a way to disable it in the toplevel.

Also, make it more robust by making the filename string mandatory.

Even better, only accept it at the beginning of a line (simply make the \n part of the token).
(0015045)
xleroy (administrator)
2015-12-05 11:16

The '# lineno filename' directive is handled directly within the lexer, so it is not particularly natural to turn it off in the toplevel.

I agree with making the filename string mandatory. The filename is always there in '# lineno filename' directives generated by ocamllex, ocamlyacc, gcc -E and clang -E.

Recognizing '#' only at beginning of line would make things more robust too. However, it's not good enough to just recognize "\n#", because it doesn't work for the first line. gcc -E and clang -E will gladly generate '# lineno filename' as the first line of output.
(0017290)
xleroy (administrator)
2017-02-16 15:33

See ongoing work in https://github.com/ocaml/ocaml/pull/931 [^]
(0018470)
gasche (administrator)
2017-10-04 11:07

Fixed in trunk (will not be in 4.06) by the aforementioned PR from Tadeu Zagallo.

- Issue History
Date Modified Username Field Change
2014-10-08 15:12 rdicosmo New Issue
2014-10-08 16:01 yallop Note Added: 0012326
2014-10-08 17:14 doligez Note Added: 0012327
2014-10-08 17:15 doligez Status new => confirmed
2014-10-08 17:15 doligez Target Version => 4.02.2+dev / +rc1
2015-02-09 21:44 doligez Steps to Reproduce Updated View Revisions
2015-02-09 21:45 doligez Target Version 4.02.2+dev / +rc1 => 4.02.3+dev
2015-07-10 18:03 doligez Target Version 4.02.3+dev => 4.03.0+dev / +beta1
2015-12-05 11:16 xleroy Note Added: 0015045
2016-04-12 15:59 doligez Target Version 4.03.0+dev / +beta1 => 4.03.1+dev
2016-04-12 15:59 doligez Tag Attached: junior_job
2017-02-16 14:01 doligez Target Version 4.03.1+dev => undecided
2017-02-16 15:33 xleroy Note Added: 0017290
2017-02-16 15:36 xleroy Target Version undecided => 4.06.0 +dev/beta1/beta2/rc1
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-02-24 13:38 doligez Category -OCaml general => lexing and parsing
2017-10-04 11:07 gasche Note Added: 0018470
2017-10-04 11:07 gasche Status confirmed => resolved
2017-10-04 11:07 gasche Fixed in Version => 4.07.0+dev/beta2/rc1/rc2
2017-10-04 11:07 gasche Resolution open => fixed
2017-10-04 11:07 gasche Assigned To => gasche


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker