unison
unison copied to clipboard
round trip error with long abilities lists
the following code fails to round trip. Once it wants to split the abilities list across multiple lines it doesn't indent the abilities enough
ability January where capricorn : {January} ()
ability February where aquarius : {February} ()
ability March where pisces : {March} ()
ability April where aries : {April} ()
ability May where taurus : {May} ()
ability June where gemini : {June} ()
ability July where cancer : {July} ()
ability August where leo : {August} ()
ability September where virgo : {September} ()
ability October where libra : {October} ()
ability November where scorpio : {November} ()
ability December where sagittarius : {December} ()
foo : a ->{January, February, March, April, May, June, July, August, September, October, November, December} a -> ()
foo a b = ()
Has this been fixed? I see this printed as
foo :
a
->{May,
February,
October,
June,
January,
November,
March,
December,
April,
September,
July,
August} a
-> ()
foo a b = ()
which parses fine.
@mitchellwrosen hmm yeah with release 0.5.19 the above example works fine for me. But the cloud client pool.wrap doesn't. If you shrink it to a single line it compiles fine. Interestingly toRemote which has a pretty similar type signature seems to roundtrip fine.
Ok, here's how pool.wrap prints
pool.wrap :
(a
->{Config,
Exception,
State,
Http,
Services,
Remote,
websockets.HttpWebSocket,
WebSockets,
Random,
Log,
Scratch} b)
-> a
->{Remote} b
pool.wrap f a = await (Remote.fork !pool do randomly do f a)
and here's the (confusing) parse error
I got confused here:
12 | Log,
I was surprised to find an end of section here.
I was expecting one of these instead:
* ,
* ->
Although it's printed hideously, I don't see why that syntax shouldn't parse. So it's a parse error? Perhaps someone more familiar with the parser could weigh in on whether that should parse or not.
Oh boy, this makes no sense to me. If you comment out the line it's complaining about...
pool.wrap :
(a
->{Config,
Exception,
State,
Http,
Services,
Remote,
websockets.HttpWebSocket,
WebSockets,
Random,
-- Log,
Scratch} b)
-> a
->{Remote} b
pool.wrap f a = await (Remote.fork !pool do randomly do f a)
it parses fine... wat
:-/ hm well see if you can minimize it. what about a different ability besides Log? or deleting the line instead of commenting it? or fewer abilities but with Log?
I can't really minimize it in a way that makes it clear what's going on. You can certainly get the error to appear and disappear just by playing around. The Log, Random, and Remote abilities seem to cause the most trouble.
In this code
pool.wrap :
(a ->{Config,
Remote,
Log,
Scratch} b)
-> a
->{Remote} b
pool.wrap f a = await (Remote.fork !pool do randomly do f a)
there is a syntax error on Remote,. The lexed tokens of that first ability list are
Open "{"
WordyId (NameOnly (Name Relative (Config :| [])))
Reserved ","
WordyId (NameOnly (Name Relative (Remote :| [])))
Semi True
Reserved ","
WordyId (NameOnly (Name Relative (Log :| [])))
Reserved ","
WordyId (NameOnly (Name Relative (Scratch :| [])))
Close
That Semi True is what's causing the error - not sure why it's appearing there! Curiously, if we swap the lexeme Remote for Exception, then the Semi True goes away.
Open "{"
WordyId (NameOnly (Name Relative (Config :| [])))
Reserved ","
WordyId (NameOnly (Name Relative (Exception :| [])))
Reserved ","
WordyId (NameOnly (Name Relative (Log :| [])))
Reserved ","
WordyId (NameOnly (Name Relative (Scratch :| [])))
Close
(a ->{Config,
Random, Scratch} b)
lexes incorrectly (erroneous Semi True) yet both of these lex correctly
Variant 1: space after Random
(a ->{Config,
Random , Scratch} b)
Variant 2: some other string than Random:
(a ->{Config,
Random2, Scratch} b)
the Semi True is coming from this line
Just an idea: I see we don't emit virtual semis inside parens. Do we also want to avoid emitting virtual semis inside curly brackets like in this example? @pchiusano maybe you would recall some of the virual semi details.
@runarorama might also know the answer to the previous question
Does it have anything to do with the outdent relative to the {?
Yeah @aryairani, it does
@mitchellwrosen Could you post a concise version of the question to #toolchain-development and if we don't learn anything new in the next couple days then plan to go it alone