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

Parser bug? strange requirement for ;; #2613

Closed
vicuna opened this issue Nov 17, 2000 · 1 comment
Closed

Parser bug? strange requirement for ;; #2613

vicuna opened this issue Nov 17, 2000 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 17, 2000

Original bug ID: 222
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: John Max Skaller
Version: 3.00
OS: Linux
Submission from: proxy4.syd.pacific.net.au (203.27.69.94)

The following works:

open List
;;
print_endline "x"
;;

Remove the first ';;' and it fails:

open List

print_endline "x"
;;

[root@pelican] ~/links/ot>ocamlc t.ml
File "t.ml", line 3, characters 0-13:
Syntax error

The following is OK:

open List
let map = map;;

Notice that no ';;' is required after the 'open'
directive here.

My guess is that the parser, at the top level, will not
accept an expression after an 'open' directive;
but it does accept a let binding. An expression is accepted,
however, if the open directive is elided, this:

let map = List.map in ();;

works fine because there is no preceding 'open'.

In the failing examples shown, the parser actually reports an
error in the expression. However, in some of my production
code, it mysteriously reports an error where the missing
';;' is needed; that is, it reports an error in columns 0-1
of a blank line, where there is no text.

@vicuna
Copy link
Author

vicuna commented Nov 26, 2000

Comment author: administrator

My guess is that the parser, at the top level, will not
accept an expression after an 'open' directive;
but it does accept a let binding.

It's simpler than that, actually: the parser doesn't accept a
top-level expression unless preceded by ";;" or "let _ =". If
you're allergic to semicolons, you can use the latter.

In the failing examples shown, the parser actually reports an
error in the expression. However, in some of my production
code, it mysteriously reports an error where the missing
';;' is needed; that is, it reports an error in columns 0-1
of a blank line, where there is no text.

If you can send a piece of code exhibiting this behaviour, we'll be
happy to fix the problem and make it report the error in some sensible
place.

-- Damien

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

1 participant