Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

polymorphic suggestion for unhandled cases in switch uses backtick #1

Closed
Coobaha opened this issue Jul 1, 2020 · 9 comments
Closed
Labels

Comments

@Coobaha
Copy link

Coobaha commented Jul 1, 2020

let withpayload = #polymorphic(3)
switch withpayload {
  | #polymoprhic(c) => Js.log(c)
}
 13 │ 
  14 │ let withpayload = #polymorphic(3)
  15 │ switch withpayload {
  16 │   | #polymoprhic(c) => Js.log(c)
  17 │ }
  18 │ 
  19 │ let array = [1,2,3]
  
  You forgot to handle a possible case here, for example: 
`polymorphic _
@Coobaha
Copy link
Author

Coobaha commented Jul 1, 2020

I should have opened this in bs-platform directly maybe.. cc @bobzhang

@chenglou
Copy link
Member

chenglou commented Jul 2, 2020

Just to make sure: you saw that you made a typo right?
And yeah this isn't syntax-related =). Thanks. Closing!

@chenglou chenglou closed this as completed Jul 2, 2020
@Coobaha
Copy link
Author

Coobaha commented Jul 2, 2020

Oh yeah 😅 error suggested case uses ` instead of #

@chenglou
Copy link
Member

chenglou commented Jul 2, 2020

Whoops my mistake. That's a printing error.

@chenglou chenglou reopened this Jul 2, 2020
@Coobaha Coobaha changed the title polymorphic switch polymorphic suggestion for unhandled cases in switch uses backtick Jul 2, 2020
@cristianoc
Copy link
Contributor

cristianoc commented Jul 2, 2020

Could be, this is about warnings (wrong syntax) vs errors (correct syntax). Unless there's another repro with errors.
CC @bobzhang

@Coobaha
Copy link
Author

Coobaha commented Jul 2, 2020

Another old issue with suggestions that exists in .re is that suggestions are printed in .ml syntax.

type myT =
  | A
  | B
  | C
  | D(int)

switch (A) {
  | A => 1
}

  26 │ switch (A) {
  27 │   | A => 1
  28 │ }
  29 │ 
  30 │ let array = [1,2,3]
  
  You forgot to handle a possible case here, for example: 
(B|C|D _)

@bobzhang
Copy link
Member

bobzhang commented Jul 3, 2020

This is a long existing issue (with refmt too), seems we need to patch
val Parmatch.pretty_val : Format.formatter -> Typedtree.pattern -> unit
cc @cristianoc @IwanKaramazow

@bobzhang
Copy link
Member

bobzhang commented Jul 8, 2020

Note there's an easy solution:

We can convert Typedtree.pattern to Parsetree.pattern
pat: mapper -> Typedtree.pattern -> pattern;
So that if res gives us a printer for Parsetree.pattern, it should work

@stale
Copy link

stale bot commented May 29, 2023

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

@stale stale bot added the stale label May 29, 2023
@stale stale bot closed this as completed Jun 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants