Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using :paste in :paste mode crashes the repl #3476

Open
natefaubion opened this issue Dec 11, 2018 · 2 comments
Open

Using :paste in :paste mode crashes the repl #3476

natefaubion opened this issue Dec 11, 2018 · 2 comments

Comments

@natefaubion
Copy link
Contributor

natefaubion commented Dec 11, 2018

It's a little silly, but we could maybe recover from it I think.

> :paste
… :paste
…
purs: An internal error occurred during compilation: "handleCommand: unexpected command"
Please report this at https://github.com/purescript/purescript/issues
CallStack (from HasCallStack):
  error, called at src/Language/PureScript/Crash.hs:24:3 in purescript-0.12.1-Cp6zGLfC9uqBgP73eCu6tr:Language.PureScript.Crash
  internalError, called at src/Language/PureScript/Interactive.hs:115:49 in purescript-0.12.1-Cp6zGLfC9uqBgP73eCu6tr:Language.PureScript.Interactive
@hdgarrood
Copy link
Contributor

This is perhaps a sign that we should just be using proper Parsec parsers throughout Language.PureScript.Interactive.Parser, rather than the current mixture of parsec parsers and String -> Either String a functions.

@hdgarrood
Copy link
Contributor

hdgarrood commented Dec 30, 2018

Actually I take that back, the way we're using Parsec doesn't seem to be related to this.

Having looked into it a little more I wonder if the issue is that we shouldn't be allowing any command inside :paste mode. I don't think

> :paste
… :k Int
… 
Type

makes a lot of sense, for instance. Looking at the Command data type,

data Command
  -- | A purescript expression
  = Expression P.Expr
  -- | Show the help (ie, list of directives)
  | ShowHelp
  -- | Import a module from a loaded file
  | Import ImportedModule
  -- | Browse a module
  | BrowseModule P.ModuleName
  -- | Exit PSCI
  | QuitPSCi
  -- | Reload all the imported modules of the REPL
  | ReloadState
  -- | Clear the state of the REPL
  | ClearState
  -- | Add some declarations to the current evaluation context
  | Decls [P.Declaration]
  -- | Find the type of an expression
  | TypeOf P.Expr
  -- | Find the kind of an expression
  | KindOf P.SourceType
  -- | Shows information about the current state of the REPL
  | ShowInfo ReplQuery
  -- | Paste multiple lines
  | PasteLines
  -- | Return auto-completion output as if pressing <tab>
  | CompleteStr String
  -- | Set the interactive printing function
  | SetInteractivePrint (P.ModuleName, P.Ident)
  deriving Show

I think the only constructors which make sense inside a :paste would be Expression, Decls, and Import. How about disallowing everything else inside :paste? We can probably give more helpful syntax errors that way, too.

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

No branches or pull requests

4 participants