I think you are seeing the intended behavior. In the first example, you're generating one Elm runtime that includes ModuleA and ModuleB, in the second example, you're generating two different elm runtimes, and that's the reason there isn't any name collision. You can easily check this by comparing the sizes and contents of combined.js and a.js, b.js.
I hope this helps you. On Monday, 22 August 2016 19:25:14 UTC+2, b123400 wrote: > > Hello, I find it confusing about ports in modules, I have sent an issue > <https://github.com/elm-lang/elm-compiler/issues/1450> but didn't get > notice for a month, so I'd like to post it here for discussion. > > I have two modules, they both have a port with the same name: > > port module ModuleA exposing (main) > import Html exposing (text)import Platform.Sub as Sub > port incomePort : (String -> msg) -> Sub msg > main = > text "Hello" > > port module ModuleB exposing (main) > import Html exposing (text)import Platform.Sub as Sub > port incomePort : (String -> msg) -> Sub msg > main = > text "Hey!" > > And I compiled it by this command: > > elm make ModuleA.elm ModuleB.elm --output combined.js > > The generated JS file will output the following error: > > Error: There can only be one port named `incomePort`, but your program has > multiple. > > These two modules are not connected and there should be no ambiguity > between the ports. I think the ports name checking should be bounded to the > module, instead of JS-file-wise. > > By the way, when I generate the modules separately and include them in the > same page, there is no error. > > elm make ModuleA.elm --output a.js > elm make ModuleB.elm --output b.js > > <script type="text/javascript" src="a.js"></script> > <script type="text/javascript" src="b.js"></script> > > Is this behaviour intended? > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.