atom-haskell-archive / haskell-ghc-mod

haskell-ghc-mod atom package
https://atom.io/packages/haskell-ghc-mod
MIT License
69 stars 20 forks source link

Uncaught TypeError: Cannot read property 'length' of undefined #3

Closed betlgtu closed 9 years ago

betlgtu commented 9 years ago

On default for yesod project Application.hs file I get Uncaught TypeError.

Atom Version: 0.180.0 System: Windows 7 Thrown From: haskell-ghc-mod package, v0.4.1

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:391

TypeError: Cannot read property 'length' of undefined
  at TextBuffer.module.exports.TextBuffer.lineLengthForRow (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:391:29)
  at TextBuffer.module.exports.TextBuffer.clipPosition (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:943:53)
  at TextBuffer.module.exports.TextBuffer.clipRange (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:925:20)
  at MarkerManager._results.push._this.(anonymous function) [as clipRange] (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\delegato\lib\delegator.js:67:61)
  at MarkerManager.module.exports.MarkerManager.markRange (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\marker-manager.js:84:20)
  at TextBuffer.module.exports.TextBuffer.markRange (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\node_modules\text-buffer\lib\text-buffer.js:645:27)
  at DisplayBuffer.module.exports.DisplayBuffer.markBufferRange (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\src\display-buffer.js:1272:41)
  at TextEditor.module.exports.TextEditor.markBufferRange (C:\Users\Bet\AppData\Local\atom\app-0.180.0\resources\app\src\text-editor.js:1309:59)
  at EditorController.module.exports.EditorController.showMessage (C:\Users\Bet\.atom\packages\haskell-ghc-mod\lib\editor-controller.coffee:51:30)
  at C:\Users\Bet\.atom\packages\haskell-ghc-mod\lib\editor-controller.coffee:1:1
  at C:\Users\Bet\.atom\packages\haskell-ghc-mod\lib\editor-controller.coffee:104:7
  at C:\Users\Bet\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process.coffee:114:9
  at Socket.<anonymous> (C:\Users\Bet\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process.coffee:62:9)
  at Socket.g (events.js:202:16)
  at Socket.emit (events.js:138:20)
  at readableAddChunk (_stream_readable.js:164:16)
  at Socket.Readable.push (_stream_readable.js:127:10)
  at Pipe.onread (net.js:530:20)

Commands

  3x -2:44.6 core:backspace (atom-text-editor.editor.mini)
     -2:41.8 core:confirm (atom-text-editor.editor.mini)
  4x -2:28.2 core:move-down (atom-text-editor.editor.mini)
     -1:54.9 editor:select-to-first-character-of-line (atom-text-editor.editor.mini)
     -1:52.4 core:confirm (atom-text-editor.editor.mini)
     -1:05.0 haskell-ghc-mod:type (atom-text-editor.editor)
     -1:03.5 pane:reopen-closed-item (atom-text-editor.editor)
     -0:54.1 git-plus:add (atom-text-editor.editor)

Config

{
  "core": {
    "themes": [
      "atom-dark-ui",
      "monokai-dark"
    ],
    "disabledPackages": [
      "build-systems"
    ]
  },
  "haskell-ghc-mod": {
    "ghcModPath": "C:\\Users\\Bet\\AppData\\Roaming\\cabal\\bin\\ghc-mod.exe",
    "ghcModiPath": "C:\\Users\\Bet\\AppData\\Roaming\\cabal\\bin\\ghc-modi.exe"
  }
}

Installed Packages

# User
autocomplete-glsl, v0.1.3
autocomplete-haskell, v0.2.0
autocomplete-paths, v1.0.2
autocomplete-plus, v2.1.6
build, v0.23.4
color-picker, v1.4.4
editor-stats, v0.17.0
editorconfig, v0.3.0
git-clone, vundefined
git-plus, v4.4.2
git-projects, v1.7.1
haskell-ghc-mod, v0.4.1
ide-haskell, v0.3.3
language-glsl, v1.0.1
language-haskell, v1.0.0
linter-hlint, v0.3.1
monokai-dark, v1.0.0

# Dev
No dev packages
lierdakil commented 9 years ago

Can't reproduce. Could you test with Atom 0.181.0? (since it looks a lot like bug in Atom 0.180.0) If it still happens, could you list actions needed to reproduce, or show a minimal example?

betlgtu commented 9 years ago

I update atom to 0.181.0. The error still. Minimal example is yesod default scaffolded site. Are you have yesod installed? On small programm (< 200 code rows) I can't reproduce error.

lierdakil commented 9 years ago

Tested with default yesod 1.4.1 site (created with yesod init with simple db). Still couldn't reproduce. Would you mind running

atom.packages.getActivePackage('haskell-ghc-mod').mainModule.process.getType(atom.workspace.getActiveEditor().getText(),atom.workspace.getActiveEditor().getSelectedBufferRange(),function(range,type){console.log(range.start); console.log(range.end); console.log(type);})

in dev console with your haskell source open and text cursor on symbol you can't get type of, and sending me its output? (it may take a couple seconds before any meaningful output) Please also include output from

atom.workspace.getActiveEditor().getBuffer().getRange().end
betlgtu commented 9 years ago

If you set cursor on import statement something like this:

import Text.Jasmine (minifym)

And then press Ctrl+Alt+I Or run your command in Dev mode:

atom.packages.getActivePackage('haskell-ghc-mod').mainModule.process.getType(atom.workspace.getActiveEditor().getText(),atom.workspace.getActiveEditor().getSelectedBufferRange(),function(range,type){console.log(range.start); console.log(range.end); console.log(type);}) undefined events.js:94 Uncaught Error: This socket has been ended by the other party atom.workspace.getActiveEditor().getBuffer().getRange().end Point {row: 150, column: 0, copy: function, negate: function, freeze: function…}

It is another error, if I press Ctrl+Alt+T

got something strange from ghc-mod type: ["ghc-mod.exe: : cannot satisfy -packa…d-static-1.4.0.3-37b95737a41b298f05cbaf886276d038", unique: function]0: "ghc-mod.exe: : cannot satisfy -package-id yesod-static-1.4.0.3-37b95737a41b298f05cbaf886276d038"length: 1

The error "Cannot read property 'length' of undefined" show me after first start of Atom. After 10-20 seconds, I see another error "This socket has been ended by the other party"

lierdakil commented 9 years ago

Ok, it makes some semblance of sense now. First, half those errors are from ide-haskell. Second, try running ghc-mod check Application.hs in your project directory. You'll likely find that ghc-mod spits out errors. Try correcting those.

Note that cabal sandboxes have very limited support both in ide-haskell and this package, so if you're using them, you may be out of luck for now.

You may also want to uncheck some ticks in haskell-ghc-mod settings, since you're using ide-haskell anyway.

Please also note, that ghc-modi does not support spaces in project path. This is a bug in ghc-mod, so nothing I can do.

lierdakil commented 9 years ago

Closing due to no activity (probably solved)

ploeh commented 9 years ago

FWIW, I'm seeing this error consistently today.

While I have experience with programming in general, I'm new to Haskell, but if you want more details, I'll be happy to supply them, if only you tell me what I need to do to obtain them.

This error message appears in the Atom editor, where I'm using these packages:

I don't expect that this in itself is enough information, but I'll be happy to provide more data upon request.

lierdakil commented 9 years ago

@ploeh, if you could create an isolated test case for this, this would be best. But I would guess that's not easy, if at all possible. If you could start with providing Atom version you're running, OS and stack traces for this error, that would probably be good enough. You can copy Atom's error report to clipboard (click little clipboard icon above "View this Issue" button on error message), which would provide this information.

ploeh commented 9 years ago

I'll see if I can chase down a simpler repro, but I'm currently working my way through Real World Haskell, having now reached chapter 5. In that chapter, the authors are explaining how to develop a library, and I'm typing in the code as I read along.

Here are some steps that seem to reproduce the issue on my machine.

Add the following files to the same directory:

SimpleJSON.hs

module SimpleJSON
  (
    JValue(..)
  , getString
  , getInt
  , getDouble
  , getBool
  , getObject
  , getArray
  , isNull
  ) where

data JValue =
    JString String
  | JNumber Double
  | JBool Bool
  | JNull
  | JObject [(String, JValue)]
  | JArray [JValue]
    deriving (Eq, Ord, Show)

getString :: JValue -> Maybe String
getString (JString s) = Just s
getString _ = Nothing

getInt (JNumber n) = Just (truncate n)
getInt _ = Nothing

getDouble (JNumber n) = Just n
getDouble _ = Nothing

getBool (JBool b) = Just b
getBool _ = Nothing

getObject (JObject o) = Just o
getObject _ = Nothing

getArray (JArray a) = Just a
getArray _ = Nothing

isNull v = v == JNull

PrettyStub.hs

module PrettyStub where

import SimpleJSON

data Doc = ToBeDefined
  deriving (Show)

-- string :: String -> Doc
-- string str = undefined

text :: String -> Doc
text str = undefined

double :: Double -> Doc
double num = undefined

(<>) :: Doc -> Doc -> Doc
a <> b = undefined
  1. Open the folder with these two files in Atom.
  2. Open the PrettyStub.hs file.
  3. Save the file (Ctrl+s, or just use the File -> Save menu). This triggers the error. It's not necessary to edit the file first.

Atom Version: 1.0.7 System: Microsoft Windows 10 Pro Thrown From: haskell-ghc-mod package, v0.8.13

Stack Trace

Uncaught TypeError: Cannot read property 'length' of undefined

At C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\util.coffee:100

TypeError: Cannot read property 'length' of undefined
    at Object.module.exports.Util.pointWithTabsRev (C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\util.coffee:142:32)
    at C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process.coffee:331:28
    at Array.forEach (native)
    at queueCmd.callback (C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process.coffee:321:17)
    at C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process.coffee:166:11
    at BufferedProcess.exit (C:\Users\mark\.atom\packages\haskell-ghc-mod\lib\ghc-modi-process-base.coffee:124:20)
    at triggerExitCallback (C:\Users\mark\AppData\Local\atom\app-1.0.7\resources\app.asar\src\buffered-process.js:213:47)
    at ChildProcess.<anonymous> (C:\Users\mark\AppData\Local\atom\app-1.0.7\resources\app.asar\src\buffered-process.js:235:18)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:169:7)

Commands

     -7:27.2.0 core:save (atom-text-editor.editor.is-focused)
     -7:27.1.0 ide-haskell:check-file (atom-text-editor.editor.is-focused)
     -7:27.1.0 ide-haskell:lint-file (atom-text-editor.editor.is-focused)
     -0:35.2.0 pane:show-next-item (atom-text-editor.editor.is-focused)
     -0:31.9.0 core:move-to-bottom (atom-text-editor.editor.is-focused)
     -0:31.4.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:21.8.0 editor:move-to-end-of-screen-line (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:12.8.0 editor:newline (atom-text-editor.editor.is-focused)
     -0:04.1.0 autocomplete-plus:confirm (atom-text-editor.editor.is-focused.autocomplete-active)
     -0:03.3.0 core:save (atom-text-editor.editor.is-focused)
     -0:03.3.0 ide-haskell:check-file (atom-text-editor.editor.is-focused)
     -0:03.3.0 ide-haskell:lint-file (atom-text-editor.editor.is-focused)

Config

{
  "core": {},
  "haskell-ghc-mod": {}
}

Installed Packages

# User
autocomplete-haskell, v0.4.5
haskell-ghc-mod, v0.8.13
ide-haskell, v0.7.1
keyboard-localization, v1.4.7
language-haskell, v1.4.1

# Dev
No dev packages
lierdakil commented 9 years ago

Mea culpa. I didn't think a fix for another issue trough. Reverted that for now, 0.8.14 should be good.

ploeh commented 9 years ago

That was fast :open_mouth:

Initial testing seems to indicate that this has resolved the problem. :+1:

Thank you