halohalospecial / atom-elmjutsu

A bag of tricks for developing with Elm. (Atom package)
https://atom.io/packages/elmjutsu
MIT License
192 stars 24 forks source link

Uncaught TypeError: Cannot read property 'split' of undefined #147

Closed aaahrens closed 5 years ago

aaahrens commented 5 years ago

[Enter steps to reproduce:]

  1. have un-typed alias at the top of a module

Atom: 1.32.2 x64 Electron: 2.0.9 OS: Mac OS X 10.14.1 Thrown From: elmjutsu package 9.9.1

Stack Trace

Uncaught TypeError: Cannot read property 'split' of undefined

At /Users/drunkengranite/.atom/packages/elmjutsu/lib/elm-make-runner.js:439

TypeError: Cannot read property 'split' of undefined
    at /packages/elmjutsu/lib/elm-make-runner.js:439:31
    at Array.map (<anonymous>)
    at /packages/elmjutsu/lib/elm-make-runner.js:437:65
    at /packages/elmjutsu/lib/eval-helper.js:49:7)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)

Commands

     -0:32.7.0 core:save (input.hidden-input)
     -0:30.7.0 core:move-down (input.hidden-input)
     -0:30.5.0 intentions:highlight (input.hidden-input)
  3x -0:30.4.0 editor:move-to-end-of-word (input.hidden-input)
     -0:29.7.0 editor:move-to-beginning-of-word (input.hidden-input)
     -0:29.3.0 editor:delete-to-beginning-of-word (input.hidden-input)
     -0:28.9.0 datatip:toggle (input.hidden-input)
     -0:28.4.0 core:backspace (input.hidden-input)
     -0:27.9.0 intentions:highlight (input.hidden-input)
  2x -0:27.8.0 editor:move-to-beginning-of-word (input.hidden-input)
     -0:27.4.0 datatip:toggle (input.hidden-input)
  2x -0:27 core:move-up (input.hidden-input)
     -0:23 core:paste (input.hidden-input)
  2x -0:22.5.0 core:save (input.hidden-input)
     -0:07.2.0 autocomplete-plus:activate (atom-text-editor.editor.is-focused)
     -0:03.4.0 core:save (input.hidden-input)

Non-Core Packages

atom-ide-ui 0.13.0 
autocomplete 0.47.0 
busy-signal 1.4.3 
elm-format 3.2.0 
elmjutsu 9.9.1 
file-icons 2.1.26 
go-plus 6.0.1 
intentions 1.1.5 
javascript-snippets 1.2.1 
jenkins 0.3.5 
language-elm 1.5.0 
language-graphql 0.11.0 
language-hcl 0.4.0 
language-jenkinsfile 0.1.1 
linter 2.2.0 
linter-ui-default 1.7.1 
markdown-preview-plus 3.7.1 
prettier-atom 0.56.0 
Stylus 3.2.0 
aaahrens commented 5 years ago

I've been getting this when there is an untyped alias or function at the top of a file. Feel free to close.

halohalospecial commented 5 years ago

Hi, can you give me sample code? Thanks!

aaahrens commented 5 years ago
module Main exposing (Model, Msg(..), aThing, init, main, update, view)

import Browser
import Html exposing (Html, div, h1, img, text)
import Html.Attributes exposing (src)

aThing =
    { aField = "" }

---- MODEL ----

type alias Model =
    {}

init : ( Model, Cmd Msg )
init =
    ( {}, Cmd.none )

---- UPDATE ----

type Msg
    = NoOp

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    ( model, Cmd.none )

---- VIEW ----

view : Model -> Html Msg
view model =
    div []
        [ img [ src "/logo.svg" ] []
        , h1 [] [ text "Your Elm App is working!" ]
        ]

---- PROGRAM ----

main : Program () Model Msg
main =
    Browser.element
        { view = view
        , init = \_ -> init
        , update = update
        , subscriptions = always Sub.none
        }
aaahrens commented 5 years ago

ripped straight from create-elm-app

aaahrens commented 5 years ago

if it helps at all, sometimes when the error gets thrown it emits the DummyElm modules into the project

halohalospecial commented 5 years ago

Hi @aaahrens, I could not reproduce the issue :(

Can you log the value of outString here: https://github.com/halohalospecial/atom-elmjutsu/blob/master/lib/elm-make-runner.js#L428

Thanks!

johnmullany commented 5 years ago

Atom: 1.33.0 Mac: Mojave Version 10.14.1 (18875) elmjutsu 9.9.1 Just doing a simple main = text "Hello world!" gives the following stack trace on save Uncaught TypeError: Cannot read property 'split' of undefined /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:439 TypeError: Cannot read property 'split' of undefined at /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:439:31 at Array.map (<anonymous>) at /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:437:65 at ChildProcess.<anonymous> (/Users/johnmullany/.atom/packages/elmjutsu/lib/eval-helper.js:49:7) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

halohalospecial commented 5 years ago

Hi @johnmullany,

Can you log the value of outString and errString here?

https://github.com/halohalospecial/atom-elmjutsu/blob/master/lib/elm-make-runner.js#L428

Thanks!

halohalospecial commented 5 years ago

Also, are you using Elm 0.18 or 0.19?

johnmullany commented 5 years ago

0.19 and sure.

johnmullany commented 5 years ago

Not sure how to get the outString and errString...sorry.

halohalospecial commented 5 years ago

@johnmullany

  1. Open /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js.
  2. Insert the following in line 428:
    console.log('errString', errString);
    console.log('outString', outString);
  3. Restart Atom.
johnmullany commented 5 years ago

I'm not getting any console errors but I do get the same error but now on line 441.

johnmullany commented 5 years ago

Step by step, I put main = "Hello world!". The module Main exposing (main) is then added for me. It shows the red underline on main which I can hover over and get the error description. I also get the same error in the diagnostics panel. When I add just the text function with the "Hello World!" string I get a new error description. Once I add the import Html exposing (..) I get the uncaught type error about the cannot read property 'split' of undefined. If I close the error at that point, I still have the same error notification that I cannot find a 'text' variable even though it is syntactically correct. Sorry I can't be of more help.

aaahrens commented 5 years ago

where do we catch stdout of the console log? @johnmullany me too >.> this package is why I'm using atom. How are you liking elm?

halohalospecial commented 5 years ago

@aaahrens, it's in /Users/drunkengranite/.atom/packages/elmjutsu/lib/elm-make-runner.js in your case.

johnmullany commented 5 years ago

Elm is great. I love it. I don't want to hijack this thread but I am anxious to hear what @aaahrens gets back from the addition of the console logs.

johnmullany commented 5 years ago

So I didn't get anything from the errString or the outString as far as the log goes so I put another console log for result on line 441 of elm-make-runner.js and get undefined for result. Split then tries to read undefined. /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:407 result line 441 undefined /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:408 Uncaught TypeError: Cannot read property 'split' of undefined at /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:442:31 at Array.map (<anonymous>) at /Users/johnmullany/.atom/packages/elmjutsu/lib/elm-make-runner.js:439:65 at ChildProcess.<anonymous> (/Users/johnmullany/.atom/packages/elmjutsu/lib/eval-helper.js:49:7) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Socket.stream.socket.on (internal/child_process.js:346:11) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at Pipe._handle.close [as _onclose] (net.js:554:12)

johnmullany commented 5 years ago

By the way, Elmjutsu is awesome. I used it before I went to Visual Studio Code and returned to Atom only because of Elmjutsu.

halohalospecial commented 5 years ago

@aaahrens @johnmullany can you try v9.9.2? Thanks!

johnmullany commented 5 years ago

On line 437 I tried const issues = _.zip(namesAndRanges, typeAnnotations); and then mapping issues issues.map(([{name, range}, result]) => { console.log('result', result); }); I get result is undefined. I'm not sure if this helps but if there is anything else I can try please let me know and I should be more prompt about a response.

johnmullany commented 5 years ago

Perfect!! v9.9.2 is working. Thanks!!!