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

Forbid function redefinitions in an OCaml module #12

Closed
leostera opened this issue Oct 10, 2020 · 0 comments
Closed

Forbid function redefinitions in an OCaml module #12

leostera opened this issue Oct 10, 2020 · 0 comments
Labels
bug Something isn't working compiler Related to the OCaml to Erlang compiler good first issue Good for newcomers help wanted Extra attention is needed

Comments

@leostera
Copy link
Owner

leostera commented Oct 10, 2020

This OCaml source code:

let f 0 = true
let f _ = false

should result in a compilation error explaining that module functions can only be defined once, and multi-clause functions are achievable by the use of the function | pattern_1 -> expr_1 | pattern_2 -> expr_2 syntax.

This currently yields a function redefinition:

f(0) -> true.
f(_) -> false.

Which is not valid Erlang.

All of the modules are available as we translate them (see OCaml_to_erlang.Fun.mk_functions) but unfortunately we do not do this with every function.

Instead we are mapping over them so they are unaware of each other.

Changing this to a fold would allow us to carry around the list of functions that have already been defined, and we could check that any is being defined twice.

@leostera leostera added bug Something isn't working help wanted Extra attention is needed compiler Related to the OCaml to Erlang compiler labels Oct 10, 2020
@leostera leostera added this to the v0.1 milestone Oct 10, 2020
@leostera leostera added the good first issue Good for newcomers label Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Related to the OCaml to Erlang compiler good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant