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

Bug #1921 #8497

Closed
vicuna opened this issue Mar 2, 2004 · 1 comment
Closed

Bug #1921 #8497

vicuna opened this issue Mar 2, 2004 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 2, 2004

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

Bug description

Hello,
I found a workaround (which is strange, IMHO) to the problem showed by the bug
#1921.
Here is a reminder:

##################################################
let rec recData=
let module SomeModule=
struct

  let callRecData x=
if x<=0
then 1
else ((fst recData) (x-1)) * x

  let mk_double x=2 * x

end

in
(SomeModule.callRecData, SomeModule.mk_double)

let _=
let test=(snd recData) ((fst recData) 5) in
print_int test
##################################################

This code compiled against 3.06 and worked as expected, while 3.07 refused it
(this kind of expression not allowed in the right-hand side of a 'let rec'...).
Here's the workaround:

##################################################
let rec recData dummy=
let module SomeModule=
struct

  let callRecData x=
if x<=0
then 1
else ((fst (recData dummy)) (x-1)) * x

  let mk_double x=2 * x

end

in
(SomeModule.callRecData, SomeModule.mk_double)

let _=
let test=(snd (recData [])) ((fst (recData [])) 5) in
print_int test
###################################################

As you see, the solution is to add one useless parameter to make 3.07 happy (and
the execution is also correct). I didn't look after the problematic piece of
code in the OCaml source code, though.

@vicuna
Copy link
Author

vicuna commented Jun 25, 2004

Comment author: administrator

see also #8362
It's normal that adding a parameter to a definition suppresses the recursion
problem.

@vicuna vicuna closed this as completed Jun 25, 2004
@vicuna vicuna added the bug label Mar 19, 2019
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