purescript-language-cst-parser icon indicating copy to clipboard operation
purescript-language-cst-parser copied to clipboard

Indented root layout not supported?

Open postsolar opened this issue 11 months ago • 4 comments

module M where

  i :: Int
  i = 1

purs-tidy check src/M.purs replies with

Some files have errors:

/home/me/purs-test/src/M.purs:
  [6:1] Unexpected end of file

postsolar avatar Mar 01 '24 13:03 postsolar

I'm pretty sure that's just invalid syntax. Top-level declarations cannot be indented.

JordanMartinez avatar Mar 01 '24 15:03 JordanMartinez

It compiles fine though? https://try.purescript.org/?code=LYewJgrgNgpgBAWQIYEsB2cDuALGAnGAKELjhTgC4K4BJNAFxLLgF44BGQoA

postsolar avatar Mar 01 '24 15:03 postsolar

This syntax was definitely supported originally because we allowed multiple modules per file, so you'd have like

module X where

  def1 :: ...

module Y where

  def2 :: ...

so it may have been preserved since then in the main compiler.

garyb avatar Mar 01 '24 15:03 garyb

I wouldn't recommend writing code this way as it's completely unnecessary (I personally think some kind of syntax error is appropriate), but if the main compiler supports it, we probably should as well.

natefaubion avatar Mar 01 '24 15:03 natefaubion