Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

Module name may cause hot swapping to fail #50

Closed
jcollard opened this issue Nov 19, 2014 · 23 comments
Closed

Module name may cause hot swapping to fail #50

jcollard opened this issue Nov 19, 2014 · 23 comments

Comments

@jcollard
Copy link
Member

Given the file AnOkayModuleName.elm with contents:

module AnOkayModuleName where
import Text (asText)
main = asText 42

If you run elm-reactor in the same directory as AnOkayModuleName.elm and debug it, hot swapping works fine. That is, you can change 42 to 45, save, and view the changes immediately.

However, changing the module name to Test and the file name to Test.elm causes hot swapping to fail. That is, it loads up fine but any change to the file (even without saving) causes the following error to be displayed in the browser:

Cannot use 'in' operator to search for 'recv' in undefined
    Open the developer console for more details.

I played around with it some more and the following file/module names also fail:

Test2, TheTest, Two, Three

It looks like anything that starts with a T will fail in the same way.

@evancz
Copy link
Contributor

evancz commented Nov 19, 2014

And this seems to be tied to the letter T? Does it work when renaming to Hats or ABC or whatever else? If so, this is pretty crazy.

@jcollard
Copy link
Member Author

It works renaming it to several other things.

I tried: BasicTest, One, and Four

@jcollard
Copy link
Member Author

You do get the same error if you rename the module to something that is not the same as the filename.

@evancz
Copy link
Contributor

evancz commented Nov 19, 2014

Here's my understanding. You go to http://localhost:8000/Test.elm and start changing code. That works. You change the module name in the Elm code itself, the file name remains Test.elm. What happens? I think it should keep working, and I'm not sure why it would not at the moment.

Now if you rename the file to anything else http://localhost:8000/Test.elm should die. I don't see how it can be otherwise.

Can you walk me through the exact thing you want and how it is going wrong?

@jcollard
Copy link
Member Author

I made a video of the problem:

https://www.youtube.com/watch?v=odV6cBySLqQ

The video follows this process:

  1. start elm-reactor in empty dir
  2. Create file called BasicTest.elm with the code from the example above (only difference is module BasicTest where)
  3. Load up debug mode in browser.
  4. Make change and observe hot swap working
  5. Change the module name to Test and save as Test.elm
  6. Load up debug mode on Test.elm
  7. As soon as any change is made to the file (even without saving) an error pops up
  8. Show a few more examples of working / not working names

It looks like modules starting with S also fail.

@evancz
Copy link
Contributor

evancz commented Nov 19, 2014

It is conceivable that this issue is related, but I don't really see the connection here. I think this needs more digging, I have no intuition.

Are you able to take a look at this? I need to get types working with elm-repl again today.

@jcollard
Copy link
Member Author

Yeah. I'll keep digging.

@eriksvedang
Copy link

I get the same error when having hot swapping activated and just starting to type in my text editor (not even saving). I'm on Mac and using 0.14.

@jcollard
Copy link
Member Author

What is the name of your module?

@eriksvedang
Copy link

I have tried a bunch – "Hej", "Test" and "Erik" I think :)

@jcollard
Copy link
Member Author

I am assuming changing the name has no effect? For me, changing the name made a difference.

@lostfictions
Copy link

Same issue here. I can't swap either of the samples in https://github.com/evancz/elm-examples. Renaming Hello.elm to AnOkayModuleName.elm doesn't fix it, UNLESS I also add the module declaration to the top of the file, as in @jcollard's opening example:

module AnOkayModuleName where

on the other hand, adding module Hello where to the top of Hello.elm without the rename doesn't help.

@ncammarata
Copy link

Also getting this with index.elm module name Index.

@ncammarata
Copy link

Additionally get

elm-reactor-unwrapped: <file descriptor: 14>: hGetBuf: invalid argument (Invalid argument)
elm-reactor-unwrapped: out of memory

in terminal when running elm-reactor, after a while, at which point elm-reactor crashes

@evancz
Copy link
Contributor

evancz commented Dec 21, 2014

I've heard a bunch of reports of this, so I'm gonna try to figure it out and maybe do a 0.14.1 release with this and some other fixes.

evancz pushed a commit that referenced this issue Dec 21, 2014
@evancz
Copy link
Contributor

evancz commented Dec 21, 2014

@jcollard, do you mind trying with the latest stuff? I think I found and fixed a bug in which the module that gets swapped in was whatever module came first alphabetically. I think it was a hack that relied on some pattern in the old code generation code, and it survived the transition to 0.14.

@jcollard
Copy link
Member Author

It doesn't seem to be crashing anymore. However, I am not getting any hot swapping when building from the master on this repo.

@jcollard
Copy link
Member Author

Wait... for some reason It shows I am using elm-compiler 0.13. I'm going to rebuild everything from scratch and try again.

@jcollard
Copy link
Member Author

This looks fixed. I cannot get it to fail anymore.

@evancz
Copy link
Contributor

evancz commented Dec 21, 2014

Phew! Thanks for trying this out! It's sort of crazy that any program
worked. This definitely deserves a 0.14.1.

On Sunday, December 21, 2014, Joseph Collard [email protected]
wrote:

Closed #50 #50.


Reply to this email directly or view it on GitHub
#50 (comment).

Sent from Gmail Mobile

@evancz
Copy link
Contributor

evancz commented Jan 9, 2015

Okay, folks can check out the 0.14.1 alpha and see if it is fixed there: https://groups.google.com/forum/#!topic/elm-discuss/KHg-aeFvDN0

@eriksvedang
Copy link

Yes, it works. Yay and thanks!

@evancz
Copy link
Contributor

evancz commented Jan 9, 2015

Great, thank you for the confirmation!

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

No branches or pull requests

5 participants