Skip to content

Puzzling infinite loop with oddly accepted program #6327

@vicuna

Description

@vicuna

Original bug ID: 6327
Reporter: @dbuenzli
Status: acknowledged (set by @mshinwell on 2014-05-30T11:46:11Z)
Resolution: open
Priority: low
Severity: tweak
Version: 4.01.0
Target version: later
Category: lexing and parsing
Tags: patch
Related to: #4627 #6961

Bug description

AFAIR my OCaml syntax this program should be rejected. It is accepted and running it (osx) results in an infinite loop.

cat t.ml

let () =
let rec loop n = match n with
| 0 -> ()
| n -> (); ; loop (n - 1)
in
loop 3

ocamlbuild t.native
Finished, 4 targets (0 cached) in 00:00:00.
time ./t.native
^C

real 0m15.264s
user 0m15.260s
sys 0m0.003s

Something must be wrong in the parsing of match branches as for example the following program is rightly rejected

cat t2.ml

let () =
let rec loop n =
if n = 0 then () else
((); ; loop (n - 1))
in
loop 3

ocamlbuild t2.native

  • /Users/dbuenzli/.opam/4.01.0/bin/ocamldep.opt -modules t2.ml > t2.ml.depends
    File "t2.ml", line 5, characters 9-10:
    Error: Syntax error: ')' expected
    File "t2.ml", line 5, characters 4-5:
    Error: This '(' might be unmatched
    Command exited with code 2.
    Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.

Thanks,

Daniel

File attachments

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions