unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

use clauses below pretty-printed term does not parse, but use clauses above does parse #5412

Open kylegoetz opened 1 month ago

kylegoetz commented 1 month ago

Describe and demonstrate the bug

branch here: https://share.unison-lang.org/@kylegoetz/finger-tree-bloated/code/@kylegoetz/parse-bug

You can either paste this in scratch or you can edit foldlWithPos and then add the use clauses beneath what the pretty printer dumps to the scratch:

``` unison
FingerTree.foldlWithPos : (b ->{g2} v ->{g1} a ->{g} b) -> b -> FingerTree v a -> b
FingerTree.foldlWithPos = todo ""

use FingerTree
use Digit

output is

```` markdown
``` umm
I got confused here:

      3 | FingerTree.foldlWithPos : (b ->{g2} v ->{g1} a ->{g} b) -> b -> FingerTree v a -> b

  I was surprised to find a ':' here.
  I was expecting one of these instead:

  * ability
  * bang
  * binding
  * do
  * false
  * force
  * [snip]


If you remove the `use` clauses from the bottom, scratch parses. If you move them to the top, scratch parses.

**Environment (please complete the following information):**
 - `ucm --version` 0.5.23
 - OS/Architecture: macOS 15.0.1, silicon
kylegoetz commented 1 month ago

update: changed URL because I moved the project to a different project name