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

Variable scoping for recursive terms + thoughts about documented options #8362

Closed
vicuna opened this issue Nov 6, 2003 · 1 comment
Closed
Labels

Comments

@vicuna
Copy link

vicuna commented Nov 6, 2003

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

Bug description

Hello,

I just found out something which I don't know if it should be qualified as a
bug or not: take a look at toy-min.ml. It compiles fine with ocaml 3.06, and
works as expected, but fails with ocaml 3.07.
This is a toy example based on a 47Ko source file (!), which compiled fine
with 3.06 but not with the new version.

The toy.ml file is the syntactic equivalent of this source file, though you
might prefer to take a look at toy-min.ml instead.

The reason why I hope :-) it is a bug, is that the incriminated source file is
generated automatically, and understanding how to correct it would cause me
headaches ;-).

I looked for the cause of this incompatibility, and saw that there had been
some changes in check_recursive_lambda of bytecomp/translcore.ml.

So I attempted to get the lambda term that caused the problem, so as to unroll
manually the check_recursive_lambda function, but I saw that when there was an
syntactic error, the lambda term was not dumped (while the parse tree was). So
maybe changing the order of function calls in driver/compile.ml would be a
good idea (but I dunno, I didn't attempt to see if the order was important or
not).

Thanks in advance.


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

module type DummyType=
sig
type t

val mk_id : t -> t
end

module MakeModule=
functor(M:DummyType) ->
struct
let fun1 a= M.mk_id a
let fun2 a= M.mk_id a
end

let first (t,,)=t
let second (,t,)=t
let third (,,t)=t

let treatment x=x
let callsthg x=x

let rec recData=
let useRecData x=callsthg (second recData x) in
let module SomeModule=
struct
type t=int

  let rec useUser somefun what=
match what with
  | None -> what
  | Some(_:int) -> treatment (useUser useRecData None)

  let callRecData x=
first recData x

  let mk_id x=x

end

in

let module UserModule=MakeModule(SomeModule) in
(UserModule.fun1, UserModule.fun2, SomeModule.useUser)



@vicuna
Copy link
Author

vicuna commented Jun 16, 2004

Comment author: administrator

See also #8497 for a follow-up.
This is not really a bug. The checking of recursive values is tighter in 3.07,
so more things are rejected.
Eta-expansion solves the problem in this case.
--DD 2004-06-16

@vicuna vicuna closed this as completed Jun 16, 2004
@vicuna vicuna mentioned this issue Mar 14, 2019
@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