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

simple recursive value not accepted #5054

Closed
vicuna opened this issue May 19, 2010 · 3 comments
Closed

simple recursive value not accepted #5054

vicuna opened this issue May 19, 2010 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented May 19, 2010

Original bug ID: 5054
Reporter: jeremy
Status: closed (set by @damiendoligez on 2010-05-20T14:57:52Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.11.2
Fixed in version: 3.12.0+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

I can't think of any reason this should fail, and the documentation about "statically constructive" expressions would seem to allow it.

jeremy:~$ ocamlc -c minimal.ml
File "minimal.ml", line 18, characters 21-53:
Error: This kind of expression is not allowed as right-hand side of `let rec'

Here's minimal.ml:

module type POINTED_SET = sig
type t
val x : t
end

module IntWith3 : POINTED_SET = struct
type t = int
let x = 3
end

(* all of these are fine *)
let rec silly_list = (IntWith3.x :: silly_list)
let rec silly_list = (Some IntWith3.x :: silly_list)
let rec silly_list = ([ IntWith3.x ] :: silly_list)
let rec silly_list = (ref IntWith3.x :: silly_list)

(* but this causes an error! *)
let rec silly_list = ([| IntWith3.x |] :: silly_list)

-Jeremy

Additional information

On Snow Leopard.

@vicuna
Copy link
Author

vicuna commented May 19, 2010

Comment author: @alainfrisch

This is caused by this case in Translcore.check_recursive_lambda:

| Lprim (Pmakearray (Pgenarray), args) -> false

This was introduced in rev 7742 ( http://caml.inria.fr/cgi-bin/viewcvs.cgi/ocaml/version/3.09/bytecomp/translcore.ml?rev=7742&r1=7175&r2=7742 ) as part of the fix for #4141.

Damien: do you remember the reason for this case? It seems to me that the default behavior (accepting the array expression if it does not refer to any variable defined in the current let-rec) should be sound.

@vicuna
Copy link
Author

vicuna commented May 20, 2010

Comment author: @damiendoligez

I don't remember exactly, but looking at the code I see there is a trap with generic arrays:
you don't know their size because it depends on their type (float or not).
This pattern should probably be moved up to check_top, and then we can do better than
the default case by doing the same as for other arrays (just check all the arguments).

I'll implement that and do some testing.

@vicuna
Copy link
Author

vicuna commented May 20, 2010

Comment author: @damiendoligez

OK. Seems to work, and I'm reasonably confident that it's sound.

@vicuna vicuna closed this as completed May 20, 2010
@vicuna vicuna added the bug label Mar 20, 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