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

Typing error: probably variable shadowing #6

Open
ThatDaleMiller opened this issue Jul 20, 2018 · 2 comments
Open

Typing error: probably variable shadowing #6

ThatDaleMiller opened this issue Jul 20, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@ThatDaleMiller
Copy link
Collaborator

The following code type checks correctly in OCaml but not in MLTS. This error seems to be a problem with shadowing variable bindings. This example is based on a problem with other code from Ki Yung Ahn.

type aa = 
        | A 
        | B;;

type bb = 
    | C 
    | F of aa;;

let f x = match x with
  | C -> A
  | F x -> B
  ;;
  
let g x = match x with
  | C -> A
  | F x -> begin 
           let gg y = match A with
             | x -> x
             in gg x
             end
  ;;


@voodoos voodoos added the bug Something isn't working label Jul 23, 2018
@voodoos
Copy link
Owner

voodoos commented Jul 25, 2018

I found the bug : the parser / translator doesn't deal properly with locally defined non-recursive functions. The following program works as intended :

type aa = 
        | A 
        | B;;

type bb = 
    | C 
    | F of aa;;

let f x = match x with
  | C -> A
  | F x -> B
  ;;
  
let g x = match x with
  | C -> A
  | F x -> begin 
           let rec gg y = match A with
             | x -> x
             in gg x
             end
  ;;

@ThatDaleMiller
Copy link
Collaborator Author

Good news. I guess this means the fix is near-at-hand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants