Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Attempted pattern matching ternary

Open bbrk24 opened this issue 1 year ago • 1 comments
trafficstars

undo := => engine = Engine.fromJSON json if json? := history.pop()
const undo = () =>(const json? = history.pop()? engine = Engine.fromJSON(json):void 0)

Workaround: put the function body on the next line

undo := =>
  engine = Engine.fromJSON json if json? := history.pop()

bbrk24 avatar May 09 '24 15:05 bbrk24

A workaround for now:

undo := =>
  engine = Engine.fromJSON json if json? := history.pop()

So this is probably specific to the "don't wrap fat arrow in braces if it's a one-line expression" rule.

edemaine avatar May 09 '24 15:05 edemaine

Looks like this works now with the recent changes: https://civet.dev/playground?code=dW5kbyA6PSA9PiBlbmdpbmUgPSBFbmdpbmUuZnJvbUpTT04ganNvbiBpZiBqc29uPyA6PSBoaXN0b3J5LnBvcCgpCg%3D%3D

STRd6 avatar Oct 09 '24 21:10 STRd6

Indeed! Probably this commit: https://github.com/DanielXMoore/Civet/pull/1441/commits/bc49fe964b2c8cca4a35e909c7e5a8a0ae2c3e84 which makes fat arrows treat postfix if like an expressionized statement.

edemaine avatar Oct 09 '24 21:10 edemaine