Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove more .re syntax leftovers #5712

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_file_groups.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type file_group = {
is_dev : bool;
generators : build_generator list;
(* output of [generators] should be added to [sources],
if it is [.ml,.mli,.re,.rei]
if it is [.ml,.mli,.res,.resi]
*)
}

Expand Down
2 changes: 1 addition & 1 deletion jscomp/bsb/bsb_file_groups.mli
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type file_group = {
(* false means not in dev mode *)
generators : build_generator list;
(* output of [generators] should be added to [sources],
if it is [.ml,.mli,.re,.rei]
if it is [.ml,.mli,.res,.resi]
*)
}

Expand Down
2 changes: 1 addition & 1 deletion jscomp/gentype/EmitJs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
("In case of type error, check the type of '" ^ valueName
^ "' in '"
^ (fileName |> ModuleName.toString)
^ ".re'" ^ " and '"
^ ".res'" ^ " and '"
^ (importPath |> ImportPath.emit)
^ "'.")
~early:true ~emitters ~name:valueNameTypeChecked ~type_
Expand Down
4 changes: 2 additions & 2 deletions jscomp/gentype/GenTypeMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ let processCmtFile cmt =
let isInterface = Filename.check_suffix cmtFile ".cmti" in
let resolver =
ModuleResolver.createLazyResolver ~config
~extensions:[ ".re"; ".res"; EmitType.shimExtension ]
~extensions:[ ".res"; EmitType.shimExtension ]
~excludeFile:(fun fname ->
fname = "React.re" || fname = "ReasonReact.re")
fname = "React.res" || fname = "ReasonReact.res")
in
let inputCMT, hasGenTypeAnnotations =
let inputCMT = readCmt cmtFile in
Expand Down
15 changes: 6 additions & 9 deletions jscomp/gentype/ModuleResolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -195,28 +195,25 @@ let apply ~resolver ~useBsDependencies moduleName =
moduleName |> Lazy.force resolver.lazyFind ~useBsDependencies

(** Resolve a reference to ModuleName, and produce a path suitable for require.
E.g. require "../foo/bar/ModuleName.ext" where ext is ".re" or ".js". *)
E.g. require "../foo/bar/ModuleName.ext" where ext is ".res" or ".js". *)
let resolveModule ~(config : Config.t) ~importExtension ~outputFileRelative
~resolver ~useBsDependencies moduleName =
let outputFileRelativeDir =
(* e.g. src if we're generating src/File.re.js *)
(* e.g. src if we're generating src/File.bs.js *)
Filename.dirname outputFileRelative
in
let outputFileAbsoluteDir = config.projectRoot +++ outputFileRelativeDir in
let moduleNameReFile =
(* Check if the module is in the same directory as the file being generated.
So if e.g. project_root/src/ModuleName.re exists. *)
outputFileAbsoluteDir +++ (ModuleName.toString moduleName ^ ".re")
in
let moduleNameResFile =
(* Check if the module is in the same directory as the file being generated.
So if e.g. project_root/src/ModuleName.res exists. *)
outputFileAbsoluteDir +++ (ModuleName.toString moduleName ^ ".res")
in
let candidate =
(* e.g. import "./Modulename.ext" *)
moduleName
|> ImportPath.fromModule ~dir:Filename.current_dir_name ~importExtension
in
if Sys.file_exists moduleNameReFile || Sys.file_exists moduleNameResFile then
if Sys.file_exists moduleNameResFile then
candidate
else
let rec pathToList path =
Expand All @@ -229,7 +226,7 @@ let resolveModule ~(config : Config.t) ~importExtension ~outputFileRelative
match moduleName |> apply ~resolver ~useBsDependencies with
| None -> candidate
| Some (resolvedModuleDir, case, bsDependencies) ->
(* e.g. "dst" in case of dst/ModuleName.re *)
(* e.g. "dst" in case of dst/ModuleName.res *)
let walkUpOutputDir =
outputFileRelativeDir |> pathToList
|> List.map (fun _ -> Filename.parent_dir_name)
Expand Down
2 changes: 1 addition & 1 deletion jscomp/gentype/Paths.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let getBsConfigFile ~projectRoot =
match bsconfig |> Sys.file_exists with true -> Some bsconfig | false -> None

(** Find the relative path from /.../bs/lib
e.g. /foo/bar/bs/lib/src/Hello.re --> src/Hello.re *)
e.g. /foo/bar/bs/lib/src/Hello.res --> src/Hello.res *)
let relativePathFromBsLib fileName =
if Filename.is_relative fileName then fileName
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Use the annotations, and definitions, from the .re file
// Use the annotations, and definitions, from the .res file
@@genType.ignoreInterface

@genType type t
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {default as makeNotChecked} from './hookExample';

import {default as defaultNotChecked} from './hookExample';

// In case of type error, check the type of 'make' in 'ImportHookDefault.re' and './hookExample'.
// In case of type error, check the type of 'make' in 'ImportHookDefault.res' and './hookExample'.
export const makeTypeChecked: React.ComponentType<{
readonly person: person;
readonly children: React.ReactNode;
Expand All @@ -20,7 +20,7 @@ export const make: unknown = makeTypeChecked as React.ComponentType<{
readonly renderMe: ImportHooks_renderMe<string>
}>;

// In case of type error, check the type of 'default' in 'ImportHookDefault.re' and './hookExample'.
// In case of type error, check the type of 'default' in 'ImportHookDefault.res' and './hookExample'.
export const defaultTypeChecked: React.ComponentType<{
readonly person: person;
readonly children: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {makeRenamed as makeRenamedNotChecked} from './hookExample';

import {foo as fooNotChecked} from './hookExample';

// In case of type error, check the type of 'makeRenamed' in 'ImportHooks.re' and './hookExample'.
// In case of type error, check the type of 'makeRenamed' in 'ImportHooks.res' and './hookExample'.
export const makeRenamedTypeChecked: React.ComponentType<{
readonly actions?: JSX.Element;
readonly person: person;
Expand All @@ -22,7 +22,7 @@ export const makeRenamed: unknown = makeRenamedTypeChecked as React.ComponentTyp
readonly renderMe: renderMe<any>
}>;

// In case of type error, check the type of 'foo' in 'ImportHooks.re' and './hookExample'.
// In case of type error, check the type of 'foo' in 'ImportHooks.res' and './hookExample'.
export const fooTypeChecked: (_1:{ readonly person: person }) => string = fooNotChecked;

// Export 'foo' early to allow circular import from the '.bs.js' file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {default as defaultNotChecked} from './';

// In case of type error, check the type of 'default' in 'ImportIndex.re' and './'.
// In case of type error, check the type of 'default' in 'ImportIndex.res' and './'.
export const defaultTypeChecked: React.ComponentType<{ readonly method?: "push" | "replace" }> = defaultNotChecked;

// Export '$$default' early to allow circular import from the '.bs.js' file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@ import {default as defaultNotChecked} from './MyMath';
import * as Curry__Es6Import from 'rescript/lib/es6/curry.js';
const Curry: any = Curry__Es6Import;

// In case of type error, check the type of 'round' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'round' in 'ImportJsValue.res' and './MyMath'.
export const roundTypeChecked: (_1:number) => number = roundNotChecked;

// Export 'round' early to allow circular import from the '.bs.js' file.
export const round: unknown = roundTypeChecked as (_1:number) => number;

// In case of type error, check the type of 'area' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'area' in 'ImportJsValue.res' and './MyMath'.
export const areaTypeChecked: (_1:point) => number = areaNotChecked;

// Export 'area' early to allow circular import from the '.bs.js' file.
export const area: unknown = areaTypeChecked as (_1:point) => number;

// In case of type error, check the type of 'returnMixedArray' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'returnMixedArray' in 'ImportJsValue.res' and './MyMath'.
export const returnMixedArrayTypeChecked: () => numberOrString[] = returnMixedArrayNotChecked;

// Export 'returnMixedArray' early to allow circular import from the '.bs.js' file.
export const returnMixedArray: unknown = returnMixedArrayTypeChecked as () => numberOrString[];

// In case of type error, check the type of 'useColor' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'useColor' in 'ImportJsValue.res' and './MyMath'.
export const useColorTypeChecked: (_1:color) => number = useColorNotChecked;

// Export 'useColor' early to allow circular import from the '.bs.js' file.
export const useColor: unknown = useColorTypeChecked as (_1:color) => number;

// In case of type error, check the type of 'higherOrder' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'higherOrder' in 'ImportJsValue.res' and './MyMath'.
export const higherOrderTypeChecked: (_1:((_1:number, _2:number) => number)) => number = higherOrderNotChecked;

// Export 'higherOrder' early to allow circular import from the '.bs.js' file.
Expand All @@ -58,7 +58,7 @@ export const higherOrder: unknown = function (Arg1: any) {
return result
} as (_1:((_1:number, _2:number) => number)) => number;

// In case of type error, check the type of 'convertVariant' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'convertVariant' in 'ImportJsValue.res' and './MyMath'.
export const convertVariantTypeChecked: (_1:variant) => variant = convertVariantNotChecked;

// Export 'convertVariant' early to allow circular import from the '.bs.js' file.
Expand All @@ -71,13 +71,13 @@ export const convertVariant: unknown = function (Arg1: any) {
: {TAG: 1, _0:result.value} as any
} as (_1:variant) => variant;

// In case of type error, check the type of 'polymorphic' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'polymorphic' in 'ImportJsValue.res' and './MyMath'.
export const polymorphicTypeChecked: <a>(_1:a) => a = polymorphicNotChecked;

// Export 'polymorphic' early to allow circular import from the '.bs.js' file.
export const polymorphic: unknown = polymorphicTypeChecked as <a>(_1:a) => a;

// In case of type error, check the type of 'default' in 'ImportJsValue.re' and './MyMath'.
// In case of type error, check the type of 'default' in 'ImportJsValue.res' and './MyMath'.
export const defaultTypeChecked: number = defaultNotChecked;

// Export '$$default' early to allow circular import from the '.bs.js' file.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {make as makeNotChecked} from './hookExample';

import * as React from 'react';

// In case of type error, check the type of 'make' in 'JSXV4.re' and './hookExample'.
// In case of type error, check the type of 'make' in 'JSXV4.res' and './hookExample'.
export const makeTypeChecked: React.ComponentType<{
readonly actions?: JSX.Element;
readonly person: person;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import {default as defaultNotChecked} from './MyInput';

// In case of type error, check the type of 'default' in 'MyInput.re' and './MyInput'.
// In case of type error, check the type of 'default' in 'MyInput.res' and './MyInput'.
export const defaultTypeChecked: React.ComponentType<{ readonly onFocus?: (_1:inputFocusEvent) => void }> = defaultNotChecked;

// Export '$$default' early to allow circular import from the '.bs.js' file.
Expand Down
9 changes: 6 additions & 3 deletions jscomp/ounit_tests/ounit_string_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ let suites =
(* __LOC__ >:: begin fun _ ->
OUnit.assert_bool __LOC__ @@
List.for_all (fun x -> Ext_string.is_valid_source_name x = Good)
["x.ml"; "x.mli"; "x.re"; "x.rei";
["x.ml"; "x.mli"; "x.res"; "x.resi";
"A_x.ml"; "ab.ml"; "a_.ml"; "a__.ml";
"ax.ml"];
OUnit.assert_bool __LOC__ @@ not @@
List.exists (fun x -> Ext_string.is_valid_source_name x = Good)
[".re"; ".rei";"..re"; "..rei"; "..ml"; ".mll~";
[".res"; ".resi";"..res"; "..resi"; "..ml"; ".mll~";
"...ml"; "_.mli"; "_x.ml"; "__.ml"; "__.rei";
".#hello.ml"; ".#hello.rei"; "a-.ml"; "a-b.ml"; "-a-.ml"
; "-.ml"
Expand Down Expand Up @@ -486,7 +486,10 @@ let suites =
(Ext_filename.module_name "a/b/c.d")
"C";
string_eq
(Ext_filename.module_name "a/b/xc.re")
(Ext_filename.module_name "a/b/xc.res")
"Xc";
string_eq
(Ext_filename.module_name "a/b/xc.resi")
"Xc";
string_eq
(Ext_filename.module_name "a/b/xc.ml")
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/ext_string_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,11 +493,11 @@ function is_valid_source_name(name) {
var x = check_any_suffix_case_then_chop(name, {
hd: ".ml",
tl: {
hd: ".re",
hd: ".res",
tl: {
hd: ".mli",
tl: {
hd: ".rei",
hd: ".resi",
tl: /* [] */0
}
}
Expand Down
4 changes: 2 additions & 2 deletions jscomp/test/ext_string_test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,9 @@ type check_result =
let is_valid_source_name name : check_result =
match check_any_suffix_case_then_chop name [
".ml";
".re";
".res";
".mli";
".rei"
".resi"
] with
| None -> Suffix_mismatch
| Some x ->
Expand Down
4 changes: 2 additions & 2 deletions lib/4.06.1/rescript.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4387,7 +4387,7 @@ type file_group = {
(* false means not in dev mode *)
generators : build_generator list;
(* output of [generators] should be added to [sources],
if it is [.ml,.mli,.re,.rei]
if it is [.ml,.mli,.res,.resi]
*)
}

Expand Down Expand Up @@ -4445,7 +4445,7 @@ type file_group = {
is_dev : bool;
generators : build_generator list;
(* output of [generators] should be added to [sources],
if it is [.ml,.mli,.re,.rei]
if it is [.ml,.mli,.res,.resi]
*)
}

Expand Down
9 changes: 6 additions & 3 deletions lib/4.06.1/unstable/all_ounit_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38647,12 +38647,12 @@ let suites =
(* __LOC__ >:: begin fun _ ->
OUnit.assert_bool __LOC__ @@
List.for_all (fun x -> Ext_string.is_valid_source_name x = Good)
["x.ml"; "x.mli"; "x.re"; "x.rei";
["x.ml"; "x.mli"; "x.res"; "x.resi";
"A_x.ml"; "ab.ml"; "a_.ml"; "a__.ml";
"ax.ml"];
OUnit.assert_bool __LOC__ @@ not @@
List.exists (fun x -> Ext_string.is_valid_source_name x = Good)
[".re"; ".rei";"..re"; "..rei"; "..ml"; ".mll~";
[".res"; ".resi";"..res"; "..resi"; "..ml"; ".mll~";
"...ml"; "_.mli"; "_x.ml"; "__.ml"; "__.rei";
".#hello.ml"; ".#hello.rei"; "a-.ml"; "a-b.ml"; "-a-.ml"
; "-.ml"
Expand Down Expand Up @@ -39061,7 +39061,10 @@ let suites =
(Ext_filename.module_name "a/b/c.d")
"C";
string_eq
(Ext_filename.module_name "a/b/xc.re")
(Ext_filename.module_name "a/b/xc.res")
"Xc";
string_eq
(Ext_filename.module_name "a/b/xc.resi")
"Xc";
string_eq
(Ext_filename.module_name "a/b/xc.ml")
Expand Down
23 changes: 10 additions & 13 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -239914,28 +239914,25 @@ let apply ~resolver ~useBsDependencies moduleName =
moduleName |> Lazy.force resolver.lazyFind ~useBsDependencies

(** Resolve a reference to ModuleName, and produce a path suitable for require.
E.g. require "../foo/bar/ModuleName.ext" where ext is ".re" or ".js". *)
E.g. require "../foo/bar/ModuleName.ext" where ext is ".res" or ".js". *)
let resolveModule ~(config : Config.t) ~importExtension ~outputFileRelative
~resolver ~useBsDependencies moduleName =
let outputFileRelativeDir =
(* e.g. src if we're generating src/File.re.js *)
(* e.g. src if we're generating src/File.bs.js *)
Filename.dirname outputFileRelative
in
let outputFileAbsoluteDir = config.projectRoot +++ outputFileRelativeDir in
let moduleNameReFile =
(* Check if the module is in the same directory as the file being generated.
So if e.g. project_root/src/ModuleName.re exists. *)
outputFileAbsoluteDir +++ (ModuleName.toString moduleName ^ ".re")
in
let moduleNameResFile =
(* Check if the module is in the same directory as the file being generated.
So if e.g. project_root/src/ModuleName.res exists. *)
outputFileAbsoluteDir +++ (ModuleName.toString moduleName ^ ".res")
in
let candidate =
(* e.g. import "./Modulename.ext" *)
moduleName
|> ImportPath.fromModule ~dir:Filename.current_dir_name ~importExtension
in
if Sys.file_exists moduleNameReFile || Sys.file_exists moduleNameResFile then
if Sys.file_exists moduleNameResFile then
candidate
else
let rec pathToList path =
Expand All @@ -239948,7 +239945,7 @@ let resolveModule ~(config : Config.t) ~importExtension ~outputFileRelative
match moduleName |> apply ~resolver ~useBsDependencies with
| None -> candidate
| Some (resolvedModuleDir, case, bsDependencies) ->
(* e.g. "dst" in case of dst/ModuleName.re *)
(* e.g. "dst" in case of dst/ModuleName.res *)
let walkUpOutputDir =
outputFileRelativeDir |> pathToList
|> List.map (fun _ -> Filename.parent_dir_name)
Expand Down Expand Up @@ -240068,7 +240065,7 @@ let getBsConfigFile ~projectRoot =
match bsconfig |> Sys.file_exists with true -> Some bsconfig | false -> None

(** Find the relative path from /.../bs/lib
e.g. /foo/bar/bs/lib/src/Hello.re --> src/Hello.re *)
e.g. /foo/bar/bs/lib/src/Hello.res --> src/Hello.res *)
let relativePathFromBsLib fileName =
if Filename.is_relative fileName then fileName
else
Expand Down Expand Up @@ -241887,7 +241884,7 @@ let emitCodeItem ~config ~emitters ~moduleItemsEmitter ~env ~fileName
("In case of type error, check the type of '" ^ valueName
^ "' in '"
^ (fileName |> ModuleName.toString)
^ ".re'" ^ " and '"
^ ".res'" ^ " and '"
^ (importPath |> ImportPath.emit)
^ "'.")
~early:true ~emitters ~name:valueNameTypeChecked ~type_
Expand Down Expand Up @@ -243649,9 +243646,9 @@ let processCmtFile cmt =
let isInterface = Filename.check_suffix cmtFile ".cmti" in
let resolver =
ModuleResolver.createLazyResolver ~config
~extensions:[ ".re"; ".res"; EmitType.shimExtension ]
~extensions:[ ".res"; EmitType.shimExtension ]
~excludeFile:(fun fname ->
fname = "React.re" || fname = "ReasonReact.re")
fname = "React.res" || fname = "ReasonReact.res")
in
let inputCMT, hasGenTypeAnnotations =
let inputCMT = readCmt cmtFile in
Expand Down
Loading