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

Warning for different module components with the same name #7430

Closed
vicuna opened this issue Dec 8, 2016 · 14 comments
Closed

Warning for different module components with the same name #7430

vicuna opened this issue Dec 8, 2016 · 14 comments

Comments

@vicuna
Copy link

vicuna commented Dec 8, 2016

Original bug ID: 7430
Reporter: @bobzhang
Status: acknowledged (set by @mshinwell on 2016-12-12T16:00:03Z)
Resolution: open
Priority: normal
Severity: feature
Category: typing

Bug description

Just realized today that the code below is possible in OCaml:

module M : sig
  class c : object end
  val c : int
  module E : sig val x : int end
  exception E
end = struct
  class c = object end
  let c = 3
  module E = struct let x = 2 end
  exception E
end;;

let _ = new M.c
let _ = 2 + M.c
let _ : exn = M.E
let _ : int = M.E.x

This is very confusing. A warning for such definitions could be useful.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @lpw25

This is intended behavior. Those things live in different namespaces.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @bobzhang

is this not discussible? I am not saying this is a bug..

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @lpw25

Well it would be a hugely backwards incompatible change, and the only benefit put forward is that it would make your code-gen easier to write, so it doesn't seem like it is a particularly viable change.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @bobzhang

We can fix it on our side(either simply reject such programs or do the name mangling). But I am very surprised to read such programs:

let v  = new M.c
let a = M.c + 3

I think spit out a warning is reasonable feature request

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @lpw25

I think spit out a warning is reasonable feature request

I agree. I'll edit the description and mark this issue unresolved.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @lpw25

(Although I'm not personally in favour of the warning)

@vicuna
Copy link
Author

vicuna commented Dec 21, 2016

Comment author: @alainfrisch

It's rather common to have values and types with the same name. Hongbo: Would you include this case in the warning? I understand that this case does not impact Bucklescript (no runtime value corresponding to types), but it would be rather incoherent to warn in other cases but not this one.

@vicuna
Copy link
Author

vicuna commented Dec 21, 2016

Comment author: @alainfrisch

either simply reject such programs or do the name mangling

You could also group extensible constructors and classes in sub-objects of the generated Javascript module (they are much less likely to be required by JS code than regular values and modules).

@vicuna
Copy link
Author

vicuna commented Dec 21, 2016

Comment author: @bobzhang

currently we take the easy route: spit out a compiler error when detecting two runtime components exported with the same name having the same name(this happens very rare in practice and probably should not pass review).
Yes, it is common to have value and type as same name, but as you said, it does not impact BuckleScript

@vicuna
Copy link
Author

vicuna commented Dec 21, 2016

Comment author: @bobzhang

if we have a warning, it could provide better error message(we can turn it into an error on our side)

@github-actions
Copy link

github-actions bot commented May 9, 2020

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 9, 2020
@Drup
Copy link
Contributor

Drup commented May 9, 2020

I don't think there is an interest towards this outside of the bucklescript compiler team. I suggest that we close this ticket for now, and you can make a PR implementing a (disabled by default) warning when you feel ready.

@bobzhang
Copy link
Member

bobzhang commented May 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants