This is the intended behavior. The strange thing about what you are trying to do is that ModuleA and ModuleB both have a function called main. Are you intending them to be a part of the same program? Programs should only have one "main" function.
If ModuleA and ModuleB are supposed to be different programs, then you should not be compiling them in the same elm-make command. I am kind of surprised that the compiler lets you do this. On Mon, Aug 22, 2016 at 10:25 AM, b123400 <b123...@gmail.com> 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. > -- 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.