Skip to content

Commit b04dc41

Browse files
committed
Reason V4 Feature [Allow multiple versions of Resaon]
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:
1 parent 9486cfb commit b04dc41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+344
-604
lines changed

docs/RELEASING.md

Lines changed: 21 additions & 3 deletions

formatTest/typeCheckedTests/expected_output/arityConversion.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
Some((1, 2, 3));
23

34
type bcd =

formatTest/typeCheckedTests/expected_output/attributes.4.04.0.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Pexp_letexception with attributes */
23
let () = {
34
[@attribute]

formatTest/typeCheckedTests/expected_output/attributes.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* This has a nice side effect when printing the terms:
88
* If a node has attributes attached to it,
99
*/;
10+
[@reason.version 3.7];
1011

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

formatTest/typeCheckedTests/expected_output/attributes.rei

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
22

33
/**Floating comment text should be removed*/;
4+
[@reason.version 3.7];
5+
46
let test: int;
57

68
/**

formatTest/typeCheckedTests/expected_output/basics.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let l =

formatTest/typeCheckedTests/expected_output/basics_no_semi.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let l =

formatTest/typeCheckedTests/expected_output/bigarraySyntax.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* https://github.com/facebook/reason/issues/2038 */
23
let my_big_array1 =
34
Bigarray.Array1.create(

formatTest/typeCheckedTests/expected_output/comments.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* **** comment */
22
/*** comment */
33
/** docstring */;
4+
[@reason.version 3.7];
5+
46
/* comment */
57
/** docstring */;
68
/*** comment */

formatTest/typeCheckedTests/expected_output/comments.rei

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
/***** comment */
99

1010
/** */;
11+
[@reason.version 3.7];
12+
1113
/*** */
1214
/**** */
1315

formatTest/typeCheckedTests/expected_output/comments.rei.4.09.0

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* **** comment */
22
/*** comment */
33
/** docstring */;
4+
[@reason.version 3.7];
5+
46
/* comment */
57
/** docstring */;
68
/*** comment */

formatTest/typeCheckedTests/expected_output/features406.4.06.0.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
module EM = {
23
/** Exception */
34

formatTest/typeCheckedTests/expected_output/features408.4.08.0.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
open {
23
type t = string;
34
};

formatTest/typeCheckedTests/expected_output/features408.4.08.0.rei

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
module X: {type t;};
23

34
module M := X;

formatTest/typeCheckedTests/expected_output/imperative.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/*

formatTest/typeCheckedTests/expected_output/jsx.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
type component = {displayName: string};
23

34
module Bar = {

formatTest/typeCheckedTests/expected_output/knownMlIssues.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* [x] fixed */
23
type t2 = (int, int); /* attributed to entire type not binding */
34

formatTest/typeCheckedTests/expected_output/knownReIssues.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/**
23
Issue 940: https://github.com/facebook/reason/issues/940
34
The parens in the exception match case with an alias,

formatTest/typeCheckedTests/expected_output/lazy.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let myComputation =
23
lazy({
34
let tmp = 10;

formatTest/typeCheckedTests/expected_output/letop.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let (let.opt) = (x, f) =>
23
switch (x) {
34
| None => None

formatTest/typeCheckedTests/expected_output/mlSyntax.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/**
44
* Testing pattern matching using ml syntax to exercise nesting of cases.
55
*/;
6+
[@reason.version 3.7];
67

78
type xyz =
89
| X

formatTest/typeCheckedTests/expected_output/mlVariants.re.4.06.1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
type polyVariantsInMl = [

formatTest/typeCheckedTests/expected_output/mlVariants.re.4.09.0

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
type polyVariantsInMl = [

formatTest/typeCheckedTests/expected_output/mutation.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/**

formatTest/typeCheckedTests/expected_output/newAST.4.06.0.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Oinherit (https://github.com/ocaml/ocaml/pull/1118) */
23
type t = {. a: string};
34

formatTest/typeCheckedTests/expected_output/oo.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
class virtual stack ('a) (init) = {

formatTest/typeCheckedTests/expected_output/patternMatching.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
type point = {
23
x: int,
34
y: int,

formatTest/typeCheckedTests/expected_output/pervasive.rei

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let (==): ('a, 'a) => bool;
23

34
let (!=): ('a, 'a) => bool;

formatTest/typeCheckedTests/expected_output/pipeFirst.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let (|.) = (x, y) => x + y;
23

34
let a = 1;

formatTest/typeCheckedTests/expected_output/reasonComments.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
3; /* - */
23
3; /*-*/
34

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
module JustString: {
23
include Map.S; /* Comment eol include */
34
};

formatTest/typeCheckedTests/expected_output/sequences.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/**

formatTest/typeCheckedTests/expected_output/specificMLSyntax.4.04.0.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
module Foo = {
23
type t = {name: string};
34
};

formatTest/typeCheckedTests/expected_output/trailing.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[@reason.version 3.7];
2+
13
let x = 0;
24
let y = 0;
35

formatTest/typeCheckedTests/expected_output/typeParameters.re

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Testing type parameters.
3-
*/
3+
*/;
4+
[@reason.version 3.8];
45

56
type threeThings('t) = ('t, 't, 't);
67
type listOf('t) = list('t);

formatTest/typeCheckedTests/input/typeParameters.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* Testing type parameters.
33
*/
4+
[@reason.version 3.8];
45

56
type threeThings<'t> = ('t, 't, 't);
67
type listOf<'t> = list<'t>;

formatTest/unit_tests/expected_output/assert.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
switch (true) {
23
| true => ()
34
| false => assert(false)

formatTest/unit_tests/expected_output/basicStructures.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let run = () => {

formatTest/unit_tests/expected_output/bigarray.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
my_big_array3.{
23
reallyLongStringThatWillDefinitelyBreakLine
34
};

formatTest/unit_tests/expected_output/bucklescript.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
bla #= 10;
23

34
bla #= Some(10);

formatTest/unit_tests/expected_output/class_types.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
class type _module ('provider_impl) = {};
23
type t;
34
class type bzz = {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
[@reason.version 3.7];
12
// file with just a single line comment

formatTest/unit_tests/expected_output/escapesInStrings.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/*

formatTest/unit_tests/expected_output/extensions.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[@reason.version 3.7];
2+
13
/* Extension sugar */
24

35
%extend

formatTest/unit_tests/expected_output/externals.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/**
23
* Tests external formatting.
34
*/

formatTest/unit_tests/expected_output/features403.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
type t =
23
| A({a: int})
34
| B;

formatTest/unit_tests/expected_output/firstClassModules.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
module Modifier = (
23
val Db.Hashtbl.create():
34
Db.Sig with type t = Mods.t

formatTest/unit_tests/expected_output/fixme.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/**
23
* Problem: In thise example, the comment should have a space after it.
34
*/

formatTest/unit_tests/expected_output/functionInfix.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let entries = ref([]);
23

34
let all = ref(0);

formatTest/unit_tests/expected_output/if.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let logTSuccess = self =>

formatTest/unit_tests/expected_output/infix.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/* - A good way to test if formatting of infix operators groups precedences

formatTest/unit_tests/expected_output/jsx.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let x =
23
<Window
34
style={

formatTest/unit_tests/expected_output/jsx_functor.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
type elt =
23
| Text(string)
34
| Group(list(elt));

formatTest/unit_tests/expected_output/lineComments.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
3; // -
23
3; //-
34

formatTest/unit_tests/expected_output/modules.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let run = () => {

formatTest/unit_tests/expected_output/modules_no_semi.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let run = () => {

formatTest/unit_tests/expected_output/object.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
type t = {.};

formatTest/unit_tests/expected_output/ocaml_identifiers.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Type names (supported with PR#2342) */
23
module T = {
34
type pub_ = unit;

formatTest/unit_tests/expected_output/pexpFun.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
let x =
23
switch (x) {
34
| Bar =>

formatTest/unit_tests/expected_output/pipeFirst.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
foo->f->g->h;
23

34
bar->f->g->h;

formatTest/unit_tests/expected_output/polymorphism.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let run = () => {

formatTest/unit_tests/expected_output/sharpop.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
foo #= bar[0];
23

34
foo##bar[0] = 3;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
[@reason.version 3.7];
12
// let x = 1

formatTest/unit_tests/expected_output/syntax.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
[@autoFormat let wrap = 80; let shift = 2];

formatTest/unit_tests/expected_output/syntax.rei

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
/**

formatTest/unit_tests/expected_output/testUtils.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
let printSection = s => {

formatTest/unit_tests/expected_output/trailing.re

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[@reason.version 3.7];
2+
13
let x = {"obj": obj};
24

35
let x = {"key": key, "keyTwo": keyTwo};

formatTest/unit_tests/expected_output/trailingSpaces.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
[@reason.version 3.7];
12
/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */
23

34
module M =

0 commit comments

Comments
 (0)