Skip to content

Commit

Permalink
Reason V4 [Stacked Diff 1/n #2605] [Allow multiple versions of Reason]
Browse files Browse the repository at this point in the history
Summary:This allows multiple versions of Reason in a single project by
inferring and recording the version of syntax used into the file in an
attribute. The attribute allows us to switch the parser and lexer on the
fly. This attribute is not the only way we can infer the version, and we
can allow project level configuration, but this is the approach that is
guaranteed to work with any build system or tooling.

Test Plan:

Reviewers:

CC:
  • Loading branch information
jordwalke committed Aug 17, 2020
1 parent 6cb30e2 commit 7f5fe7e
Show file tree
Hide file tree
Showing 98 changed files with 1,630 additions and 678 deletions.
24 changes: 21 additions & 3 deletions docs/RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,32 @@ and `rtop.json` respectively in the repo root, you would run that script after
committing/bumping some versions:


**IMPORTANT: Update The Version Numbers In Packages:**
1. Make sure the version number in `esy.json` and `reason.json` is the new
version number for the release.
2. Make sure the file
[../../src/reason-version/reason_version.ml](../../src/reason-version/reason_version.ml)
also has that same version number that `refmt` has:

```sh
git checkout -b MYRELEASE origin/master
git rebase origin/master
vim -O esy.json reason.json
# Then edit the version number accordingly on BOTH files. With that same VERSION do:
version=3.5.0 make pre_release
vim -O esy.json reason.json src/reason-version/reason_version.ml

# Edit version field in jsons, and make sure reason_version has the new version
# let package_version = {
# major = 3;
# minor = 7;
# patch = 0;
# }

git commit -m "Bump version"
git push origin HEAD:PullRequestForVersion # Commit these version bumps

```

**Perform The Release:**
```sh
node ./scripts/esy-prepublish.js ./reason.json ./rtop.json

# Then publish. For example:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
Some((1, 2, 3));

type bcd =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Pexp_letexception with attributes */
let () = {
[@attribute]
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/attributes.re
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* This has a nice side effect when printing the terms:
* If a node has attributes attached to it,
*/;
[@reason.version 3.7];

/**Floating comment text should be removed*/;

Expand Down
2 changes: 2 additions & 0 deletions formatTest/typeCheckedTests/expected_output/attributes.rei
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

/**Floating comment text should be removed*/;
[@reason.version 3.7];

let test: int;

/**
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/basics.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

let l =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

let l =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* https://github.com/facebook/reason/issues/2038 */
let my_big_array1 =
Bigarray.Array1.create(
Expand Down
2 changes: 2 additions & 0 deletions formatTest/typeCheckedTests/expected_output/comments.re
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* **** comment */
/*** comment */
/** docstring */;
[@reason.version 3.7];

/* comment */
/** docstring */;
/*** comment */
Expand Down
2 changes: 2 additions & 0 deletions formatTest/typeCheckedTests/expected_output/comments.rei
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
/***** comment */

/** */;
[@reason.version 3.7];

/*** */
/**** */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* **** comment */
/*** comment */
/** docstring */;
[@reason.version 3.7];

/* comment */
/** docstring */;
/*** comment */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* **** comment */
/*** comment */
/** docstring */;
[@reason.version 3.7];

/* comment */
/** docstring */;
/*** comment */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* **** comment */
/*** comment */
/** docstring */;
[@reason.version 3.7];

/* comment */
/** docstring */;
/*** comment */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* **** comment */
/*** comment */
/** docstring */;
[@reason.version 3.7];

/* comment */
/** docstring */;
/*** comment */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
module EM = {
/** Exception */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
open {
type t = string;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
module X: {type t;};

module M := X;
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/imperative.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

/*
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/jsx.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
type component = {displayName: string};

module Bar = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* [x] fixed */
type t2 = (int, int); /* attributed to entire type not binding */

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/**
Issue 940: https://github.com/facebook/reason/issues/940
The parens in the exception match case with an alias,
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/lazy.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
let myComputation =
lazy({
let tmp = 10;
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/letop.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
let (let.opt) = (x, f) =>
switch (x) {
| None => None
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/mlSyntax.re
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* Testing pattern matching using ml syntax to exercise nesting of cases.
*/;
[@reason.version 3.7];

type xyz =
| X
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/mlVariants.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

type polyVariantsInMl = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

type polyVariantsInMl = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

type polyVariantsInMl = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

type polyVariantsInMl = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

type polyVariantsInMl = [
Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/mutation.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */
type t = {. a: string};

Expand Down
1 change: 1 addition & 0 deletions formatTest/typeCheckedTests/expected_output/oo.re
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[@reason.version 3.7];
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */

class virtual stack ('a) (init) = {
Expand Down

0 comments on commit 7f5fe7e

Please sign in to comment.