diff --git a/CHANGELOG.md b/CHANGELOG.md index 33651b6311..464773082b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ #### :boom: Breaking Change +- Make `j` and `js` allowed names for tag functions. https://github.com/rescript-lang/rescript-compiler/pull/6817 - `lazy` syntax is no longer supported. If you're using it, use `Lazy` module or `React.lazy_` instead. https://github.com/rescript-lang/rescript-compiler/pull/6342 - Remove handling of attributes with `bs.` prefix (`@bs.as` -> `@as` etc.). https://github.com/rescript-lang/rescript-compiler/pull/6643 - Remove obsolete `@bs.open` feature. https://github.com/rescript-lang/rescript-compiler/pull/6629 diff --git a/jscomp/build_tests/super_errors/expected/jinterp.res.expected b/jscomp/build_tests/super_errors/expected/jinterp.res.expected index 7eb7ad35cb..82d06d2f91 100644 --- a/jscomp/build_tests/super_errors/expected/jinterp.res.expected +++ b/jscomp/build_tests/super_errors/expected/jinterp.res.expected @@ -1,9 +1,9 @@ We've found a bug for you! - /.../fixtures/jinterp.res:3:10-21 + /.../fixtures/jinterp.res:3:9 1 │ 2 │ let a = 11 - 3 │ let b = j`number $(a)` + 3 │ let b = j`number $(a)` - The unsafe j`$(a)$(b)` interpolation was removed, use string template `${a}${b}` instead. \ No newline at end of file + The value j can't be found \ No newline at end of file diff --git a/jscomp/frontend/ast_utf8_string_interp.ml b/jscomp/frontend/ast_utf8_string_interp.ml index a66d7ee1f7..ee4ae0f7e1 100644 --- a/jscomp/frontend/ast_utf8_string_interp.ml +++ b/jscomp/frontend/ast_utf8_string_interp.ml @@ -280,12 +280,8 @@ module Delim = struct type interpolation = | Js (* string interpolation *) | Unrecognized (* no interpolation: delimiter not recognized *) - let parse_unprocessed loc = function + let parse_unprocessed = function | "js" -> Js - | "j" -> - Location.raise_errorf ~loc - "The unsafe j`$(a)$(b)` interpolation was removed, use string template \ - `${a}${b}` instead." | _ -> Unrecognized let escaped_j_delimiter = "*j" (* not user level syntax allowed *) @@ -294,14 +290,14 @@ module Delim = struct end let transform_exp (e : Parsetree.expression) s delim : Parsetree.expression = - match Delim.parse_unprocessed e.pexp_loc delim with + match Delim.parse_unprocessed delim with | Js -> let js_str = Ast_utf8_string.transform e.pexp_loc s in {e with pexp_desc = Pexp_constant (Pconst_string (js_str, Delim.escaped))} | Unrecognized -> e let transform_pat (p : Parsetree.pattern) s delim : Parsetree.pattern = - match Delim.parse_unprocessed p.ppat_loc delim with + match Delim.parse_unprocessed delim with | Js -> let js_str = Ast_utf8_string.transform p.ppat_loc s in {p with ppat_desc = Ppat_constant (Pconst_string (js_str, Delim.escaped))} diff --git a/jscomp/syntax/src/res_core.ml b/jscomp/syntax/src/res_core.ml index c77084669b..f2f2f9393e 100644 --- a/jscomp/syntax/src/res_core.ml +++ b/jscomp/syntax/src/res_core.ml @@ -2104,7 +2104,7 @@ and parse_primary_expr ~operand ?(no_call = false) p = ~end_pos:expr.pexp_loc.loc_end p (Diagnostics.message "Tagged template literals are currently restricted to names like: \ - json`null`."); + myTagFunction`foo ${bar}`."); parse_template_expr p) | _ -> expr in @@ -2279,11 +2279,10 @@ and parse_binary_expr ?(context = OrdinaryExpr) ?a p prec = and parse_template_expr ?prefix p = let part_prefix = - (* we could stop treating js and j prefix as something special - for json, we would first need to remove @as(json`true`) feature *) + (* we could stop treating json prefix as something special + but we would first need to remove @as(json`true`) feature *) match prefix with - | Some {txt = Longident.Lident (("js" | "j" | "json") as prefix); _} -> - Some prefix + | Some {txt = Longident.Lident ("json" as prefix); _} -> Some prefix | _ -> Some "js" in @@ -2367,8 +2366,7 @@ and parse_template_expr ?prefix p = in match prefix with - | Some {txt = Longident.Lident ("js" | "j" | "json"); _} | None -> - gen_interpolated_string () + | Some {txt = Longident.Lident "json"; _} | None -> gen_interpolated_string () | Some lident_loc -> gen_tagged_template_call lident_loc (* Overparse: let f = a : int => a + 1, is it (a : int) => or (a): int => diff --git a/jscomp/syntax/tests/conversion/reason/expected/string.res.txt b/jscomp/syntax/tests/conversion/reason/expected/string.res.txt index a85d0bbc5b..dde635285c 100644 --- a/jscomp/syntax/tests/conversion/reason/expected/string.res.txt +++ b/jscomp/syntax/tests/conversion/reason/expected/string.res.txt @@ -11,14 +11,14 @@ let y = "\n" (<> {"\n"->React.string} ) // The `//` should not result into an extra comment -let x = j`https://www.apple.com` +let x = `https://www.apple.com` let x = `https://www.apple.com` let x = `https://www.apple.com` let x = `https://www.apple.com` let x = sql`https://www.apple.com` // /* */ should not result in an extra comments -let x = j`/* https://www.apple.com */` +let x = `/* https://www.apple.com */` let x = `/* https://www.apple.com*/` let x = `/*https://www.apple.com*/` let x = `/*https://www.apple.com*/` diff --git a/jscomp/syntax/tests/conversion/reason/string.res b/jscomp/syntax/tests/conversion/reason/string.res index a85d0bbc5b..dde635285c 100644 --- a/jscomp/syntax/tests/conversion/reason/string.res +++ b/jscomp/syntax/tests/conversion/reason/string.res @@ -11,14 +11,14 @@ let y = "\n" (<> {"\n"->React.string} ) // The `//` should not result into an extra comment -let x = j`https://www.apple.com` +let x = `https://www.apple.com` let x = `https://www.apple.com` let x = `https://www.apple.com` let x = `https://www.apple.com` let x = sql`https://www.apple.com` // /* */ should not result in an extra comments -let x = j`/* https://www.apple.com */` +let x = `/* https://www.apple.com */` let x = `/* https://www.apple.com*/` let x = `/*https://www.apple.com*/` let x = `/*https://www.apple.com*/` diff --git a/jscomp/syntax/tests/idempotency/bs-css/Css_AtomicTypes.res b/jscomp/syntax/tests/idempotency/bs-css/Css_AtomicTypes.res index 18d29352bf..bbf835c94a 100644 --- a/jscomp/syntax/tests/idempotency/bs-css/Css_AtomicTypes.res +++ b/jscomp/syntax/tests/idempotency/bs-css/Css_AtomicTypes.res @@ -1802,7 +1802,7 @@ module Content = { | #noOpenQuote => "no-open-quote" | #noCloseQuote => "no-close-quote" | #attr(name) => "attr(" ++ (name ++ ")") - | #text(string) => j`"$string"` + | #text(string) => `"$string"` } } diff --git a/jscomp/syntax/tests/idempotency/bs-css/Css_Js_Core.res b/jscomp/syntax/tests/idempotency/bs-css/Css_Js_Core.res index eacb481386..104a398967 100644 --- a/jscomp/syntax/tests/idempotency/bs-css/Css_Js_Core.res +++ b/jscomp/syntax/tests/idempotency/bs-css/Css_Js_Core.res @@ -1690,8 +1690,8 @@ let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, src ->Belt.Array.map(x => switch x { - | #localUrl(value) => j`local("$(value)")` - | #url(value) => j`url("$(value)")` + | #localUrl(value) => `local("$(value)")` + | #url(value) => `url("$(value)")` } ) ->join(", ") @@ -1710,7 +1710,7 @@ let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, "font-display: " ++ (FontDisplay.toString(f) ++ ";") ) - j`@font-face { + `@font-face { font-family: $fontFamily; src: $src; $(fontStyle) diff --git a/jscomp/syntax/tests/idempotency/bs-css/Css_Legacy_Core.res b/jscomp/syntax/tests/idempotency/bs-css/Css_Legacy_Core.res index 1470459138..ed928be91e 100644 --- a/jscomp/syntax/tests/idempotency/bs-css/Css_Legacy_Core.res +++ b/jscomp/syntax/tests/idempotency/bs-css/Css_Legacy_Core.res @@ -1701,8 +1701,8 @@ let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, src |> List.map(x => switch x { - | #localUrl(value) => j`local("$(value)")` - | #url(value) => j`url("$(value)")` + | #localUrl(value) => `local("$(value)")` + | #url(value) => `url("$(value)")` } ) |> String.concat(", ") @@ -1721,7 +1721,7 @@ let fontFace = (~fontFamily, ~src, ~fontStyle=?, ~fontWeight=?, ~fontDisplay=?, "font-display: " ++ (FontDisplay.toString(f) ++ ";") ) - j`@font-face { + `@font-face { font-family: $fontFamily; src: $src; $(fontStyle) diff --git a/jscomp/syntax/tests/idempotency/covid-19charts.com/src/UseQueryParam.res b/jscomp/syntax/tests/idempotency/covid-19charts.com/src/UseQueryParam.res index dadfa1e61d..a79a98b100 100644 --- a/jscomp/syntax/tests/idempotency/covid-19charts.com/src/UseQueryParam.res +++ b/jscomp/syntax/tests/idempotency/covid-19charts.com/src/UseQueryParam.res @@ -28,7 +28,7 @@ let hook = (makeInitial, ~queryFragment, ~coder) => { { open Window - window.history.replaceState(. state, "", j`$protocol//$host$pathname$search`) + window.history.replaceState(. state, "", `$protocol//$host$pathname$search`) } None diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/FriendsPage.res b/jscomp/syntax/tests/idempotency/nook-exchange/FriendsPage.res index e82639b1a5..b3402424ec 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/FriendsPage.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/FriendsPage.res @@ -243,7 +243,7 @@ module Followee = { })} /> - :
{React.string(followee.username ++ (" has no items! " ++ j`😞`))}
} + :
{React.string(followee.username ++ (" has no items! " ++ `😞`))}
} : React.null} diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/ImportPage.res b/jscomp/syntax/tests/idempotency/nook-exchange/ImportPage.res index a25c9039ba..ea6e735d20 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/ImportPage.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/ImportPage.res @@ -148,11 +148,11 @@ type itemDestination = [ let itemDestinationToEmoji = destination => switch destination { - | #ForTrade => j`🤝` - | #CanCraft => j`🔨` - | #CatalogOnly => j`📖` - | #Wishlist => j`🙏` - | #Ignore => j`🤝` + | #ForTrade => `🤝` + | #CanCraft => `🔨` + | #CatalogOnly => `📖` + | #Wishlist => `🙏` + | #Ignore => `🤝` } module VariantRow = { @@ -729,7 +729,7 @@ let make = (~showLogin, ~url: ReasonReactRouter.url) => { setIsFetchingFromCatalogScanner(_ => true) %Repromise.Js({ let response = Fetch.fetchWithInit( - j`https://ehsan.lol/$catalogScannerId/raw`, + `https://ehsan.lol/$catalogScannerId/raw`, Fetch.RequestInit.make(~method_=Get, ~mode=CORS, ()), ) setIsFetchingFromCatalogScanner(_ => false) diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/ItemCard.res b/jscomp/syntax/tests/idempotency/nook-exchange/ItemCard.res index a898bd57eb..d50455c84b 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/ItemCard.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/ItemCard.res @@ -544,9 +544,9 @@ let make = (~item: Item.t, ~isLoggedIn, ~showLogin) => { {React.string( switch userItem.status { - | Wishlist => j`In your Wishlist` - | ForTrade => j`In your For Trade list` - | CanCraft => j`In your Can Craft list` + | Wishlist => `In your Wishlist` + | ForTrade => `In your For Trade list` + | CanCraft => `In your Can Craft list` | _ => raise(Constants.Uhoh) }, )} diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/ItemDetailOverlay.res b/jscomp/syntax/tests/idempotency/nook-exchange/ItemDetailOverlay.res index 9f0406f9f8..5aeee3e4aa 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/ItemDetailOverlay.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/ItemDetailOverlay.res @@ -391,9 +391,9 @@ module MyStatusSection = { {React.string( switch userItem.status { - | Wishlist => j`In your Wishlist` - | ForTrade => j`In your For Trade list` - | CanCraft => j`In your Can Craft list` + | Wishlist => `In your Wishlist` + | ForTrade => `In your For Trade list` + | CanCraft => `In your Can Craft list` | _ => raise(Constants.Uhoh) }, )} diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/SettingsStore.res b/jscomp/syntax/tests/idempotency/nook-exchange/SettingsStore.res index 3f8e0aa9f6..5e941cbbb7 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/SettingsStore.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/SettingsStore.res @@ -35,20 +35,20 @@ let languages: array = [ let languageToString = (language: language) => switch language { - | #German => j`Deutsch` - | #SpanishEurope => j`Español (Europe)` - | #SpanishAmerica => j`Español (America)` - | #FrenchEurope => j`Français (Europe)` - | #FrenchAmerica => j`Français (America)` - | #Italian => j`Italiano` - | #Japanese => j`日本語` - | #Korean => j`한국어` - | #Dutch => j`Nederlands` - | #Russian => j`Русский` - | #ChineseSimplified => j`中文` - | #ChineseTraditional => j`繁體中文` - | #English => j`English` - | #EnglishEurope => j`English (UK)` + | #German => `Deutsch` + | #SpanishEurope => `Español (Europe)` + | #SpanishAmerica => `Español (America)` + | #FrenchEurope => `Français (Europe)` + | #FrenchAmerica => `Français (America)` + | #Italian => `Italiano` + | #Japanese => `日本語` + | #Korean => `한국어` + | #Dutch => `Nederlands` + | #Russian => `Русский` + | #ChineseSimplified => `中文` + | #ChineseTraditional => `繁體中文` + | #English => `English` + | #EnglishEurope => `English (UK)` } @val @scope("navigator") diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/User.res b/jscomp/syntax/tests/idempotency/nook-exchange/User.res index 3cc9dd36f4..fa33238944 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/User.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/User.res @@ -7,10 +7,10 @@ type itemStatus = let itemStatusToEmoji = itemStatus => switch itemStatus { - | Wishlist => j`🙏` - | ForTrade => j`🤝` - | CanCraft => j`🔨` - | CatalogOnly => j`📖` + | Wishlist => `🙏` + | ForTrade => `🤝` + | CanCraft => `🔨` + | CatalogOnly => `📖` } let itemStatusToString = itemStatus => switch itemStatus { diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/UserItemCard.res b/jscomp/syntax/tests/idempotency/nook-exchange/UserItemCard.res index 8baf0841cb..bfed1efb7e 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/UserItemCard.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/UserItemCard.res @@ -211,7 +211,7 @@ let make = ( onBlur className=Styles.catalogStatusButton ref={ReactDOMRe.Ref.domRef(ref)}> - {React.string(userItemStatus == Some(ForTrade) ? j`🤝` : j`🔨`)} + {React.string(userItemStatus == Some(ForTrade) ? `🤝` : `🔨`)} } | _ => React.null diff --git a/jscomp/syntax/tests/idempotency/nook-exchange/ViewingList.res b/jscomp/syntax/tests/idempotency/nook-exchange/ViewingList.res index 34cb16fb72..e4a2a29e27 100644 --- a/jscomp/syntax/tests/idempotency/nook-exchange/ViewingList.res +++ b/jscomp/syntax/tests/idempotency/nook-exchange/ViewingList.res @@ -21,10 +21,10 @@ let urlToViewingList = url => } let viewingListToEmoji = viewingList => switch viewingList { - | Wishlist => j`🙏` - | ForTrade => j`🤝` - | CanCraft => j`🔨` - | Catalog => j`📖` + | Wishlist => `🙏` + | ForTrade => `🤝` + | CanCraft => `🔨` + | Catalog => `📖` } let viewingListToString = viewingList => switch viewingList { diff --git a/jscomp/syntax/tests/idempotency/reason-react-hackernews/StoryData.res b/jscomp/syntax/tests/idempotency/reason-react-hackernews/StoryData.res index 3cf06c3255..372559cff2 100644 --- a/jscomp/syntax/tests/idempotency/reason-react-hackernews/StoryData.res +++ b/jscomp/syntax/tests/idempotency/reason-react-hackernews/StoryData.res @@ -2,9 +2,9 @@ open Belt let apiBaseUrl = "https://serverless-api.hackernewsmobile.com" -let topStoriesUrl = page => j`$apiBaseUrl/topstories-25-$page.json` +let topStoriesUrl = page => `$apiBaseUrl/topstories-25-$page.json` -let storyUrl = id => j`$apiBaseUrl/stories/$id.json` +let storyUrl = id => `$apiBaseUrl/stories/$id.json` type story = { by: string, diff --git a/jscomp/syntax/tests/idempotency/reasonml.org/components/Navigation.res b/jscomp/syntax/tests/idempotency/reasonml.org/components/Navigation.res index f43f1ebda7..5a046cb376 100644 --- a/jscomp/syntax/tests/idempotency/reasonml.org/components/Navigation.res +++ b/jscomp/syntax/tests/idempotency/reasonml.org/components/Navigation.res @@ -88,7 +88,7 @@ module CollapsibleLink = { let useOutsideClick: (ReactDOMRe.Ref.t, unit => unit) => unit = %raw( (outerRef, trigger) => - j`{ + `{ function handleClickOutside(event) { if (outerRef.current && !outerRef.current.contains(event.target)) { trigger(); @@ -107,7 +107,7 @@ let useOutsideClick: (ReactDOMRe.Ref.t, unit => unit) => unit = %raw( let useWindowWidth: unit => option = %raw( () => - j`{ + `{ const isClient = typeof window === 'object'; function getSize() { diff --git a/jscomp/syntax/tests/idempotency/reasonml.org/layouts/DocsLayout.res b/jscomp/syntax/tests/idempotency/reasonml.org/layouts/DocsLayout.res index 8d49d93f68..0251284f37 100644 --- a/jscomp/syntax/tests/idempotency/reasonml.org/layouts/DocsLayout.res +++ b/jscomp/syntax/tests/idempotency/reasonml.org/layouts/DocsLayout.res @@ -57,7 +57,7 @@ module Sidebar = { {Belt.Array.map(items, m => { let hidden = isHidden ? "hidden" : "block" let active = isItemActive(m) - ? j` bg-primary-15 text-primary-dark rounded -mx-2 px-2 font-bold block ` + ? ` bg-primary-15 text-primary-dark rounded -mx-2 px-2 font-bold block ` : "" let activeToc = switch getActiveToc { @@ -144,7 +144,7 @@ module Sidebar = {