ghc "impossible" triggered when alignmentLimit set to 0 #88

Closed
opened 2017-12-21 19:45:29 +01:00 by chreekat · 8 comments
chreekat commented 2017-12-21 19:45:29 +01:00 (Migrated from github.com)

Input:

x =
  let g   = "foo"
      ghi = "bar"
  in  g ++ ghi

Output (after setting conf_layout.lconfig_alignmentLimit: 0)

brittany: panic! (the 'impossible' happened)
  (GHC version 8.0.2 for x86_64-unknown-linux):
	Prelude.maximum: empty list

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
Input: ``` x = let g = "foo" ghi = "bar" in g ++ ghi ``` Output (after setting conf_layout.lconfig_alignmentLimit: 0) ``` brittany: panic! (the 'impossible' happened) (GHC version 8.0.2 for x86_64-unknown-linux): Prelude.maximum: empty list Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug ```
lspitzner commented 2017-12-21 19:58:50 +01:00 (Migrated from github.com)

No ghc bug; the panic is just a side-effect of an exception in chunks passed to the ghc parser. Of course stilll a bug in brittany. Hope you only reported it here so far :p

No `ghc` bug; the panic is just a side-effect of an exception in chunks passed to the ghc parser. Of course stilll a bug in `brittany`. Hope you only reported it here so far :p
lspitzner commented 2017-12-21 20:01:16 +01:00 (Migrated from github.com)
most likely due to this: [`colAggregation xs = maximum [ x | x <- xs, x < minimum xs + alignMax ]`](https://github.com/lspitzner/brittany/blob/ac10b903af3d6814dc52e78e8ad52a81a20d3ee1/src/Language/Haskell/Brittany/Internal/Backend.hs#L355).
chreekat commented 2017-12-21 20:19:59 +01:00 (Migrated from github.com)

I tried making that total, but it didn't seem to help. And yeah I'm only reporting here. :) Even if it ends up being a bug lower down, I wouldn't know where in the dep tree it might be.

I tried making that total, but it didn't seem to help. And yeah I'm only reporting here. :) Even if it ends up being a bug lower down, I wouldn't know where in the dep tree it might be.
lspitzner commented 2017-12-21 21:25:15 +01:00 (Migrated from github.com)

Btw, even if it should not crash, this value does not make much sense semantically: lconfig_columnAlignMode: ColumnAlignModeDisabled is probably more suited to express "only use up to 0 spaces to achieve alignment". What effect were you going for with this config?

Btw, even if it should not crash, this value does not make much sense semantically: `lconfig_columnAlignMode: ColumnAlignModeDisabled` is probably more suited to express "only use up to 0 spaces to achieve alignment". What effect were you going for with this config?
chreekat commented 2017-12-21 21:29:03 +01:00 (Migrated from github.com)

Indeed, setting it to 1 gives the behavior I desire. Which I suppose is
equivalent to disabling column align mode? I was just flailing at the
config file to see what effect different settings had, and I'm still
figuring out what some of them mean. :)

Edit: Oh, I suppose setting it to 1 would still align things if it was a mere 1-character difference. So yes, ColumnAlignModeDisabled may in fact be what I want!

Indeed, setting it to 1 gives the behavior I desire. Which I suppose is equivalent to disabling column align mode? I was just flailing at the config file to see what effect different settings had, and I'm still figuring out what some of them mean. :) Edit: Oh, I suppose setting it to 1 would still align things if it was a mere 1-character difference. So yes, ColumnAlignModeDisabled may in fact be what I want!
lspitzner commented 2017-12-21 21:31:47 +01:00 (Migrated from github.com)

And I cannot reproduce after making it total via maximum . (0 :)

And I cannot reproduce after making it total via `maximum . (0 :)`
chreekat commented 2017-12-21 21:34:21 +01:00 (Migrated from github.com)

Aha, I was using colAggregation [] = {0|maxBound}

At this point, I think this is a fairly low-priority bug: I won't mind if you close it (though I leave it up to you). Thanks! So far I like brittany a lot.

Aha, I was using `colAggregation [] = {0|maxBound}` At this point, I think this is a fairly low-priority bug: I won't mind if you close it (though I leave it up to you). Thanks! So far I like brittany a lot.
lspitzner commented 2017-12-21 21:49:20 +01:00 (Migrated from github.com)

thanks! I have included two fixes to be sure. Having <= instead of < there is probably more correct anyways.

thanks! I have included two fixes to be sure. Having `<=` instead of `<` there is probably more correct anyways.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#88
There is no content yet.