Skip to content

Extend quoting functionality to include polyvariant keywords - #877

Merged
zth merged 2 commits into
rescript-lang:masterfrom
WhyThat:polyvar-exhaustive-switch
Dec 19, 2023
Merged

zth merged 2 commits into
rescript-lang:masterfrom
WhyThat:polyvar-exhaustive-switch

Conversation

@WhyThat

@WhyThat WhyThat commented Dec 19, 2023

Copy link
Copy Markdown
Contributor

Hey,
Following up #870, we have now extended the functionality to also wrap polyvariant keywords with quotes.

@WhyThat
WhyThat force-pushed the polyvar-exhaustive-switch branch from ebc3063 to 9aa86e8 Compare December 19, 2023 11:44
@zth

zth commented Dec 19, 2023

Copy link
Copy Markdown
Member

Great stuff! Can you add a changelog?

@WhyThat

WhyThat commented Dec 19, 2023

Copy link
Copy Markdown
Contributor Author

@zth Done :)
Just thinking about it, we could use fileNameHasUnallowedChars to detect if we have to wrap exotic polyvariant, wyt ?

@zth

zth commented Dec 19, 2023

Copy link
Copy Markdown
Member

@zth Done :) Just thinking about it, we could use fileNameHasUnallowedChars to detect if we have to wrap exotic polyvariant, wyt ?

I don't think that's equivalent to what we do, right? Doesn't that check that the string is capitalized etc?

@zth
zth merged commit d77ca15 into rescript-lang:master Dec 19, 2023
@WhyThat

WhyThat commented Dec 19, 2023

Copy link
Copy Markdown
Contributor Author

I don't think that's equivalent to what we do, right? Doesn't that check that the string is capitalized etc?

Seems like it match the same things after testing these cases :

let printMaybeExoticIdent txt =
  (* fileNameHasUnallowedChars "not good" (* => true *); *)
  (* fileNameHasUnallowedChars "not-good" (* => true *); *)
  (* fileNameHasUnallowedChars "good"(* => false *); *)
  (* fileNameHasUnallowedChars "Good"(* => false *); *)
  (* fileNameHasUnallowedChars "123"(* => false *); *)
  match (Res_token.isKeywordTxt txt, fileNameHasUnallowedChars txt) with
  | true, _ | _, true -> "\"" ^ txt ^ "\""
  | _ -> txt

test are unchanged with this, but nevermind

@WhyThat
WhyThat deleted the polyvar-exhaustive-switch branch December 19, 2023 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants