From 4dbb917fcc4289862c9d59486bc93a18a8bf7883 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 26 Apr 2016 18:43:14 -0700 Subject: [PATCH] fix rebase conflicts and bugs --- .../expected_output/basicStructures.re | 88 +++--- .../unit_tests/expected_output/comments.re | 32 +- .../unit_tests/expected_output/syntax.re | 181 +++++------ .../unit_tests/expected_output/variants.re | 36 --- .../expected_output/wrappingTest.re | 296 +++++++++--------- src/reason_toolchain.ml | 8 +- 6 files changed, 290 insertions(+), 351 deletions(-) diff --git a/formatTest/unit_tests/expected_output/basicStructures.re b/formatTest/unit_tests/expected_output/basicStructures.re index 14eb55967..7c9f4e919 100644 --- a/formatTest/unit_tests/expected_output/basicStructures.re +++ b/formatTest/unit_tests/expected_output/basicStructures.re @@ -1,4 +1,4 @@ -// Copyright (c) 2015-present, Facebook, Inc. All rights reserved. +/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ let run () => TestUtils.printSection "Basic Structures"; while something { @@ -36,7 +36,7 @@ let x = !(!foo).bar; let x = !(!foo)#bar; -// Prefix operator +/* Prefix operator */ let x = !!foo.bar; let x = !!foo#bar; @@ -64,9 +64,9 @@ let x = !!foo.bar; let x = !!foo#bar; -// Comments -//Below is an empty comment -// +/* Comments */ +/*Below is an empty comment*/ +/**/ /** IF *============================================================================ */ @@ -109,7 +109,7 @@ let loop appTime frameTime => { process appTime frameTime }; -// These parens should be kept around the entire last if/then/else +/* These parens should be kept around the entire last if/then/else */ if something { if somethingElse { () @@ -118,7 +118,7 @@ if something { } }; -// These parens should be kept around just the last if/then +/* These parens should be kept around just the last if/then*/ if something { if somethingElse { () @@ -137,7 +137,7 @@ if true { } }; -// Should print two +/* Should print two */ if true { if false { print_string "one" @@ -146,7 +146,7 @@ if true { } }; -// Should not print +/* Should not print */ if false { if true { print_string "one" @@ -209,7 +209,7 @@ if printIfFirstArgGreater { } }; -// Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear +/* Should Be Parsed As: Cleary a type error, but at least the parsing makes that clear */ if printIfFirstArgGreater { fun a b => if (a > b) { @@ -227,7 +227,7 @@ fun a b => print_string "a > b" }; -// What you probably wanted was: +/* What you probably wanted was: */ if printIfFirstArgGreater { fun a b => if (a > b) { @@ -240,7 +240,7 @@ if printIfFirstArgGreater { } }; -// Mutative if statement: Not used to evaluate to something. +/* Mutative if statement: Not used to evaluate to something. */ if (10 < 100) { let msg = "If there was any doubt, 10 is in fact less than 100."; print_string msg @@ -266,12 +266,12 @@ let x: int = 10; let x: int = (10: int); -// let (x:int) = (10:string); -// let (x:string) = ("hello":int); +/* let (x:int) = (10:string); */ +/* let (x:string) = ("hello":int); */ /** TUPLES *============================================================================ */ -// In Reason, types look like the data they model! Tuples are no exception. +/* In Reason, types look like the data they model! Tuples are no exception. */ type pairOfInts = (int, int); let letBindingWithTypeConstraint: int = 10; @@ -281,7 +281,7 @@ let (tupleItem: int, withTypeConstraint: int) = ( 20 ); -// To make sure that tuple field annotations are annotating the entire field +/* To make sure that tuple field annotations are annotating the entire field */ let _dummyFunc x => 10; let annotatingFuncApplication = ( @@ -289,14 +289,14 @@ let annotatingFuncApplication = ( _dummyFunc "a": int ); -// Pretty printer might stick the [int] at the label. +/* Pretty printer might stick the [int] at the label. */ let annotatingSingleFuncApplication: int = _dummyFunc "a"; -// So lets try a place where it won't +/* So lets try a place where it won't */ let annotatingSingleFuncApplication = { - // Commenting a let binding. + /* Commenting a let binding. */ let a = 100; - // Commenting another let binding. + /* Commenting another let binding. */ let int = 200; /* * This demonstrates why named arguments cannot simply have the form (func @@ -324,17 +324,17 @@ let (tupleItem, withOutsideTypeConstraint): ( /** Immutable Lists * ============================================================================ */ -// Anatomy: -Head- --------- Tail--------- nil: You can't see nil +/* Anatomy: -Head- --------- Tail--------- nil: You can't see nil */ let x: list int = [1, 2, 3, 4, 5, 6, 7, 8, 9]; let hd = "appendedToHead"; let tl = ["listTo", "append", "to"]; -// To push *one* and only *one* item to the front of a list - use [hd, ...tl] +/* To push *one* and only *one* item to the front of a list - use [hd, ...tl] */ let result: list string = [hd, ...tl]; -// Is the same as writing +/* Is the same as writing */ let result: list string = [ "appendedToHead", "listTo", @@ -342,13 +342,13 @@ let result: list string = [ "to" ]; -// To operate on lists, use pattern matching +/* To operate on lists, use pattern matching */ let rec size = fun | [] => 0 | [hd, ...tl] => 1 + size tl; -// Optimize for tail recursion +/* Optimize for tail recursion */ let rec size soFar lst => switch lst { | [] => 0 @@ -410,15 +410,15 @@ let MyThing _ as ppp | YourThing _ as ppp = ppp; * But this isn't needed in Reason because OR patterns have much lower * precedence - they should be pretty printed in the same way. */ -// TODO: -// let rec nestedMatch lstLst => match lstLst with { -// hd::tl: match tl with { -// []: 0 + 0, -// tlHd::tlTl: 0 + 1, -// }, -// []: 0 -// }; -// +/* TODO: */ +/* let rec nestedMatch lstLst => match lstLst with { */ +/* hd::tl: match tl with { */ +/* []: 0 + 0, */ +/* tlHd::tlTl: 0 + 1, */ +/* }, */ +/* []: 0 */ +/* }; */ +/* */ /** ARRAYS * ============================================================================ * Arrays are weird looking. Usually you want lists because they support pattern @@ -433,11 +433,11 @@ let arrayWithTwo = [|10, 10|]; let secondItem = arrayWithTwo.(1); -// Getting And Setting: Yeah, we should really change this -// Get an array item at index 1 +/* Getting And Setting: Yeah, we should really change this */ +/* Get an array item at index 1 */ let secondItem = arrayWithTwo.(1); -// Set an array item at index 1 +/* Set an array item at index 1 */ arrayWithTwo.(1) = 300; /** @@ -447,7 +447,7 @@ arrayWithTwo.(1) = 300; */ let myString = "asdf"; -// Replacing a character: I could do without this sugar +/* Replacing a character: I could do without this sugar */ myString.[2] = '9'; /* FUNCTIONS @@ -460,20 +460,20 @@ let one = 900; let two = 10000; -// Tuple expressions can be annotated without additional paren wrapping +/* Tuple expressions can be annotated without additional paren wrapping */ let myTuple = (one: int, two: int); type myTupleType = (int, int); let myTuple: myTupleType = myTuple; -// Anything *outside* of a tuple, must still be annotated within parens. +/* Anything *outside* of a tuple, must still be annotated within parens. */ let myTuple: myTupleType = (one: int, two: int); -// Now functions that accept a single argument being a tuple look familiar +/* Now functions that accept a single argument being a tuple look familiar */ let addValues (a: int, b: int) => a + b; -// Impossible to annotate return values of fun lambdas - just like in OCaml +/* Impossible to annotate return values of fun lambdas - just like in OCaml */ let addValues (a: int, b: int) => a + b; let functionReturnValueType @@ -489,7 +489,7 @@ let curriedFormTwo (i: int, x: int) :(int, int) => ( x ); -// let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x); +/* let nonCurriedFormTwo = fun (i:int, x:int) (:(int, int)) => (i, x); */ let curriedFormThree (i: int, (a: int, b: int): (int, int)) :(int, int, int) => ( @@ -498,7 +498,7 @@ let curriedFormThree b ); -// let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b); +/* let nonCurriedFormThree = fun (i:int, (a:int, b:int):(int, int)) (:(int, int, int)) => (i, a, b); */ /** TODO: But this, however doesn't work. * let (myCurriedFunc: int => int) a => a; * Note: This is likely because only "simple patterns" are accepted as constraints diff --git a/formatTest/unit_tests/expected_output/comments.re b/formatTest/unit_tests/expected_output/comments.re index e60564d62..7777dd07e 100644 --- a/formatTest/unit_tests/expected_output/comments.re +++ b/formatTest/unit_tests/expected_output/comments.re @@ -23,19 +23,17 @@ let testPostComment = ""; let testMultiline a => switch a { // single line comment - | `Thingy x => { - print_string - /* multiline comment should be fine */ - "matched thingy x"; - let zz = 10; - // post line single line comment - zz - } - | `Other x => { - // single line comment above - print_string "matched other x"; - x - } + | `Thingy x => + print_string + /* multiline comment should be fine */ + "matched thingy x"; + let zz = 10; + // post line single line comment + zz + | `Other x => + // single line comment above + print_string "matched other x"; + x }; // single line comment below @@ -66,14 +64,18 @@ let a = 10; let b = 20; /*A*/ -let named /* a::a */ a::a /* b::b */ b::b => /* a + b */ a + b; +let named /* a::a */ a::a /* b::b */ b::b => + /* a + b */ + a + b; /*B*/ let namedAlias /* a::aa */ a::aa /* b::bb */ - b::bb => /* aa + bb */ aa + bb; + b::bb => + /* aa + bb */ + aa + bb; /*C*/ let namedAnnot diff --git a/formatTest/unit_tests/expected_output/syntax.re b/formatTest/unit_tests/expected_output/syntax.re index 96754d3bc..b127e689a 100644 --- a/formatTest/unit_tests/expected_output/syntax.re +++ b/formatTest/unit_tests/expected_output/syntax.re @@ -1,4 +1,4 @@ -// Copyright (c) 2015-present, Facebook, Inc. All rights reserved. +/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ [@@@autoFormat let wrap = 80; let shift = 2; @@ -14,11 +14,11 @@ BasicStructures.run (); TestUtils.printSection "General Syntax"; -// Won't work! -// let matchingFunc a = match a with -// `Thingy x => (print_string "matched thingy x"); x -// | `Other x => (print_string "matched other x"); x;; -// +/* Won't work! */ +/* let matchingFunc a = match a with */ +/* `Thingy x => (print_string "matched thingy x"); x */ +/* | `Other x => (print_string "matched other x"); x;; */ +/* */ let matchingFunc a => switch a { | `Thingy x => @@ -39,7 +39,7 @@ type allParensCanBeRemoved = type firstTwoShouldBeGroupedAndFirstThree = ((int => int) => int) => int; -// Same thing now but with type constructors instead of each int +/* Same thing now but with type constructors instead of each int */ type firstTwoShouldBeGroupedInParens = (list int => list int) => list int => list int; @@ -67,7 +67,7 @@ type allParensCanBeRemoved = type firstTwoShouldBeGroupedAndFirstThree = first::((int => int) => int) => int; -// Same thing now, but with type constructors instead of int +/* Same thing now, but with type constructors instead of int */ type firstNamedArgShouldBeGroupedInParens = first::(list int => list int) => second::list int => @@ -113,7 +113,7 @@ type noParensNeeded = type firstNamedArgNeedsParens = one::(int => int => int) => two::int => int; -// Now, let's try type aliasing +/* Now, let's try type aliasing */ /* Unless wrapped in parens, types between arrows may not be aliased, may not * themselves be arrows. */ type parensRequiredAroundFirstArg = @@ -132,7 +132,7 @@ type myTypeDef 'a = list 'a; type instatiatedTypeDef = myTypeDef int => int; -// Test a type attribute for good measure +/* Test a type attribute for good measure */ /* We should clean up all of the attribute tagging eventually, but for now, * let's make it super ugly to get out of the way of all the formatting/parsing * implementations (fewer conflicts during parsing, fewer edge cases during @@ -162,15 +162,15 @@ constraint 'a = (unit, unit); type onelineConstrain = 'a constraint 'a = int; -// This must be in trunk but not in this branch of OCaml -// type withNestedRecords = MyConstructor of {myField: int} +/* This must be in trunk but not in this branch of OCaml */ +/* type withNestedRecords = MyConstructor of {myField: int} */ type colors = | Red of int | Black of int | Green of int; -// Another approach is to require declared variants to wrap any record -// type myRecord = MyRecord of {name: int}; -// let myValue = MyRecord {name: int}; -// This would force importing of the module +/* Another approach is to require declared variants to wrap any record */ +/* type myRecord = MyRecord of {name: int}; */ +/* let myValue = MyRecord {name: int}; */ +/* This would force importing of the module */ /* This would also lend itself naturally to pattern matching - and avoid having to use `.` operator at all since you normally destructure. */ type nameBlahType = {nameBlah: int}; @@ -329,7 +329,7 @@ type hiredPerson = { let o: person = {name: "bob", age: 10}; -// Parens needed? Nope! +/* Parens needed? Nope! */ let o: person = {name: "bob", age: 10}; let printPerson (p: person) => { @@ -337,21 +337,21 @@ let printPerson (p: person) => { p.name ^ p.name }; -// let dontParseMeBro x y:int = x = y; -// With this unification, anywhere eyou see `= fun` you can just ommit it -// Done +/* let dontParseMeBro x y:int = x = y;*/ +/* With this unification, anywhere eyou see `= fun` you can just ommit it */ +/* Done */ let blah a => a; -// Done (almost) +/* Done (almost) */ let blah a => a; -// Done +/* Done */ let blah a b => a; -// Done (almost) +/* Done (almost) */ let blah a b => a; -// More than one consecutive pattern must have a single case +/* More than one consecutive pattern must have a single case */ type blah = {blahBlah: int}; let blah a {blahBlah} => a; @@ -378,12 +378,12 @@ let onlyDoingThisTopLevelLetToBypassTopLevelSequence = { let x = { print_int 1; - // Missing trailing SEMI + /* Missing trailing SEMI */ print_int 20 }; let x = { print_int 1; - // Ensure missing middle SEMI reported well + /* Ensure missing middle SEMI reported well */ print_int 20; print_int 20 }; @@ -391,7 +391,7 @@ let print_int 1; print_int 20; 10 - // Missing final SEMI + /* Missing final SEMI */ }; x + x }; @@ -417,14 +417,14 @@ Printf.printf "\nproof that thisReturnsA: %n\n" (thisReturnsA ()); -// Pattern matching +/* Pattern matching */ let blah arg => switch arg { - // Comment before Bar - // Comment between bar/pattern + /* Comment before Bar */ + /* Comment between bar/pattern */ | Red _ => 1 - // Comment Before non-first bar - // Comment betwen bar/pattern + /* Comment Before non-first bar */ + /* Comment betwen bar/pattern */ | Black _ => 0 | Green _ => 0 }; @@ -437,16 +437,15 @@ let blah = | Black _ => 0 | Green _ => 1; -// `fun a => a` is read as "a function that maps a to a". Then the -// above example is read: "a function that 'either maps' Red to.. or maps .." -// Thc00f564e first bar is read as "either maps" +/* `fun a => a` is read as "a function that maps a to a". Then the */ +/* above example is read: "a function that 'either maps' Red to.. or maps .." */ +/* Thc00f564e first bar is read as "either maps" */ /* Curried form is not supported: let blah x | Red _ => 1 | Black _ => 0; Theres no sugar rule for dropping => fun, only = fun */ -// See, nothing says we can drop the => fun +/* See, nothing says we can drop the => fun */ let blahCurriedX x => -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 fun /* With some effort, we can ammend the sugar rule that would */ | Red x @@ -456,18 +455,8 @@ let blahCurriedX x => | Black x => 0 /* Support that */ | Green x => 0; -======= - fun // With some effort, we can ammend the sugar rule that would - | Red x - | Black x - | Green x => 1 - // Allow us to drop any => fun.. Just need to make pattern matching - | Black x => 0 - // Support that - | Green x => 0; ->>>>>>> update old tests - -// This should be parsed/printed exactly as the previous + +/* This should be parsed/printed exactly as the previous */ let blahCurriedX x => fun | Red x @@ -476,10 +465,10 @@ let blahCurriedX x => | Black x => 0 | Green x => 0; -// Any time there are multiple match cases we require a leading BAR +/* Any time there are multiple match cases we require a leading BAR */ let v = Red 10; -// So this NON-function still parses +/* So this NON-function still parses */ let Black x | Red x | Green x = v; /* This doesn't parse, however (and it doesn't in OCaml either): @@ -514,24 +503,24 @@ let res = { print_int b }; -// let result = LyList.map (fun | [] => true | _ => false) []; +/* let result = LyList.map (fun | [] => true | _ => false) []; */ /* OTHERWISE: You cannot tell if a is the first match case falling through or * a curried first arg */ -// let blah = fun a | patt => 0 | anotherPatt => 1; -// let blah a patt => 0 | anotherPatt => 1; -//simple pattern EQUALGREATER expr +/* let blah = fun a | patt => 0 | anotherPatt => 1; */ +/* let blah a patt => 0 | anotherPatt => 1; */ +/*simple pattern EQUALGREATER expr */ let blah a {blahBlah} => a; -// match_case -// pattern EQUALGREATER expr +/* match_case */ +/* pattern EQUALGREATER expr */ let blah = fun | Red _ => 1 | Black _ => 0 | Green _ => 0; -// Won't work! -// let arrowFunc = fun a b => print_string "returning aplusb from arrow"; a + b;; +/* Won't work! */ +/* let arrowFunc = fun a b => print_string "returning aplusb from arrow"; a + b;; */ let arrowFunc a b => { print_string "returning aplusb from arrow"; a + b @@ -556,7 +545,7 @@ dummy res2; dummy res3; -// Some edge cases +/* Some edge cases */ let myFun firstArg (Red x | Black x | Green x) => firstArg + x; let matchesWithWhen a => @@ -605,7 +594,7 @@ let result = myRecordWithFunctions.addThreeNumbersTupled ( let lookTuplesRequireParens = (1, 2); -// let thisDoesntParse = 1, 2; +/* let thisDoesntParse = 1, 2; */ let tupleInsideAParenSequence = { print_string "look, a tuple inside a sequence"; let x = 10; @@ -628,7 +617,7 @@ let makeIncrementer (delta: int) :(int => int) => */ let myAnnotatedValBinding: int = 10; -// Class functions (constructors) and methods are unified in the same way +/* Class functions (constructors) and methods are unified in the same way */ class classWithNoArg = { method x = 0; method y = 0; @@ -663,7 +652,7 @@ type stillARecord = {name: string, age: int}; /* Rebase latest OCaml to get the following: And fixup `generalized_constructor_arguments` according to master. */ -// type ('a, 'b) myOtherThing = Leaf of {first:'a, second: 'b} | Null; +/* type ('a, 'b) myOtherThing = Leaf of {first:'a, second: 'b} | Null; */ type branch 'a 'b = {first: 'a, second: 'b}; type myOtherThing 'a 'b = @@ -673,11 +662,11 @@ type yourThing = myOtherThing int int; /* Conveniently - this parses exactly how you would intend! No *need* to wrap in an extra [], but it doesn't hurt */ -// FIXME type lookAtThesePolyVariants = list [`Red] ; -// FIXME type bracketsGroupMultipleParamsAndPrecedence = list (list (list [`Red])); -// FIXME type youCanWrapExtraIfYouWant = (list [`Red]); -// FIXME type hereAreMultiplePolyVariants = list [`Red | `Black]; -// FIXME type hereAreMultiplePolyVariantsWithOptionalWrapping = list ([`Red | `Black]); +/* FIXME type lookAtThesePolyVariants = list [`Red] ; */ +/* FIXME type bracketsGroupMultipleParamsAndPrecedence = list (list (list [`Red])); */ +/* FIXME type youCanWrapExtraIfYouWant = (list [`Red]); */ +/* FIXME type hereAreMultiplePolyVariants = list [`Red | `Black]; */ +/* FIXME type hereAreMultiplePolyVariantsWithOptionalWrapping = list ([`Red | `Black]); */ /* /* Proposal: ES6 style lambdas: */ @@ -736,91 +725,91 @@ let a = 10; let b = 20; -//A +/*A*/ let named a::a b::b => a + b; type named = a::int => b::int => int; -//B +/*B*/ let namedAlias a::aa b::bb => aa + bb; let namedAlias a::aa b::bb => aa + bb; type namedAlias = a::int => b::int => int; -//C +/*C*/ let namedAnnot a::(a: int) b::(b: int) => 20; -//D +/*D*/ let namedAliasAnnot a::(aa: int) b::(bb: int) => 20; -//E +/*E*/ let myOptional a::a=? b::b=? () => 10; type named = a::int? => b::int? => unit => int; -//F +/*F*/ let optionalAlias a::aa=? b::bb=? () => 10; -//G +/*G*/ let optionalAnnot a::(a: int)=? b::(b: int)=? () => 10; -//H +/*H*/ let optionalAliasAnnot a::(aa: int)=? b::(bb: int)=? () => 10; -//I: +/*I: */ let defOptional a::a=10 b::b=10 () => 10; type named = a::int? => b::int? => unit => int; -//J +/*J*/ let defOptionalAlias a::aa=10 b::bb=10 () => 10; -//K +/*K*/ let defOptionalAnnot a::(a: int)=10 b::(b: int)=10 () => 10; -//L +/*L*/ let defOptionalAliasAnnot a::(aa: int)=10 b::(bb: int)=10 () => 10; -//M: Invoking them - Punned +/*M: Invoking them - Punned */ let resNotAnnotated = named a::a b::b; -//N: +/*N:*/ let resAnnotated: int = named a::a b::b; -//O: Invoking them +/*O: Invoking them */ let resNotAnnotated = named a::a b::b; -//P: Invoking them +/*P: Invoking them */ let resAnnotated: int = named a::a b::b; -//Q: Here's why "punning" doesn't work! -// Is b:: punned with a final non-named arg, or is b:: supplied b as one named arg? +/*Q: Here's why "punning" doesn't work! */ +/* Is b:: punned with a final non-named arg, or is b:: supplied b as one named arg? */ let b = 20; let resAnnotated = named a::a b::b; -//R: Proof that there are no ambiguities with return values being annotated +/*R: Proof that there are no ambiguities with return values being annotated */ let resAnnotated: ty = named a::a b; -//S: Explicitly passed optionals are a nice way to say "use the default value" +/*S: Explicitly passed optionals are a nice way to say "use the default value"*/ let explictlyPassed = myOptional a::?None b::?None; -//T: Annotating the return value of the entire function call +/*T: Annotating the return value of the entire function call */ let explictlyPassedAnnotated: int = myOptional a::?None b::?None; -//U: Explicitly passing optional with identifier expression +/*U: Explicitly passing optional with identifier expression */ let a = None; let explictlyPassed = myOptional a::?a b::?None; @@ -964,22 +953,22 @@ let something = | [_, ..._] => "nonEmptyList" ); -// A | B = X; +/* A | B = X; */ let A | B = X; -// A | (B | C) = X; +/* A | (B | C) = X; */ let A | (B | C) = X; -// (A | B) | (C | D) = X; +/* (A | B) | (C | D) = X; */ let A | B | (C | D) = X; -// A | B | (C | D) = X; +/* A | B | (C | D) = X; */ let A | B | (C | D) = X; -// (A | B) | C = X; +/* (A | B) | C = X; */ let A | B | C = X; -// A | B | C = X; +/* A | B | C = X; */ let A | B | C = X; /** External function declaration diff --git a/formatTest/unit_tests/expected_output/variants.re b/formatTest/unit_tests/expected_output/variants.re index 587d1efda..03ee3d777 100644 --- a/formatTest/unit_tests/expected_output/variants.re +++ b/formatTest/unit_tests/expected_output/variants.re @@ -142,8 +142,6 @@ let accessDeeplyWithArg x => let rec accessDeeplyWithArgRecursive x count => switch x { | LocalModule.AccessedThroughModuleWith x as entirePattern => -<<<<<<< 3fe786e63e3337d160facc736e0d5b9f8d6e4c06 -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 /* It captures the whole pattern */ if (count > 0) { 0 @@ -159,26 +157,6 @@ let rec accessDeeplyWithArgRecursive x count => accessDeeplyWithArgRecursive entirePattern (count - 1) } -======= - // It captures the whole pattern -======= - /* It captures the whole pattern */ ->>>>>>> Revert "update old tests" - if (count > 0) { - 0 - } else { - accessDeeplyWithArgRecursive - entirePattern (count - 1) - } - | LocalModule.AccessedThroughModuleWithTwo x y as entirePattern => - /* It captures the whole pattern */ - if (count > 0) { - 0 - } else { - accessDeeplyWithArgRecursive - entirePattern (count - 1) - } ->>>>>>> update old tests }; accessDeeplyWithArgRecursive @@ -245,16 +223,10 @@ let rec commentPolymorphicCases: 'a . option 'a => int = -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 fun | Some a => 1 /* Comment on one */ | None => 0; -======= - fun | Some a => 1 - /* Comment on one */ - | None => 0; ->>>>>>> update old tests let thisWontCompileButLetsSeeHowItFormats = switch something { @@ -278,20 +250,12 @@ type term _ = | App of (term ('b => 'a)) (term 'b) :term 'a; let rec eval: type a. term a => a = -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 fun | Int n => n /* a = int */ | Add => (fun x y => x + y) /* a = int => int => int */ | App f x => (eval f) (eval x); -======= - fun | Int n => n - /* a = int */ - | Add => (fun x y => x + y) - /* a = int => int => int */ - | App f x => (eval f) (eval x); ->>>>>>> update old tests let rec eval: type a. term a => a = fun x => diff --git a/formatTest/unit_tests/expected_output/wrappingTest.re b/formatTest/unit_tests/expected_output/wrappingTest.re index 702869164..f271f6287 100644 --- a/formatTest/unit_tests/expected_output/wrappingTest.re +++ b/formatTest/unit_tests/expected_output/wrappingTest.re @@ -1,5 +1,5 @@ -// Copyright (c) 2015-present, Facebook, Inc. All rights reserved. -// Run the formatting pretty printer with width 50 +/* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. */ +/* Run the formatting pretty printer with width 50 */ /* * Testing infix wrapping */ @@ -13,7 +13,7 @@ let something = reallyLongIdent; let something = - // Hopefully + /* Hopefully */ reallyLongIdent + /* It will indent like this */ andYetAnotherReallyLongIdent + @@ -96,17 +96,12 @@ let a = 10; let b = 20; -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 /*A*/ let named /* a::a */ a::a /* b::b */ b::b => /* a + b */ a + b; -======= -//A -let named /* a::a */ a::a /* b::b */ b::b => /* a + b */ a + b; ->>>>>>> update old tests -//B +/*B*/ let namedAlias /* a::aa */ a::aa @@ -115,25 +110,25 @@ let namedAlias /* aa + bb */ aa + bb; -//C +/*C*/ let namedAnnot /* a::(a: option int) */ a::(a: option int) /* b::(b: option int) */ b::(b: option int) => - // 20 + /* 20 */ 20; -//D +/*D*/ let namedAliasAnnot /* a::(aa: option int) */ a::(aa: option int) /* b::(bb: option int) */ b::(bb: option int) => - // 20 + /* 20 */ 20; -//E +/*E*/ let optional /* a::a=? */ a::a=? @@ -141,10 +136,10 @@ let optional b::b=? /* () */ () => - // 10 + /* 10 */ 10; -//F +/*F*/ let optionalAlias /* a::aa */ a::aa=? @@ -152,10 +147,10 @@ let optionalAlias b::bb=? /* () */ () => - // 10 + /* 10 */ 10; -//G +/*G*/ let optionalAnnot /* a::(a: option int)=? */ a::(a: option int)=? @@ -163,10 +158,10 @@ let optionalAnnot b::(b: option int)=? /* () */ () => - // 10 + /* 10 */ 10; -//H +/*H*/ let optionalAliasAnnot /* a::(aa: option int)=? */ a::(aa: option int)=? @@ -174,10 +169,10 @@ let optionalAliasAnnot b::(bb: option int)=? /* () => */ () => - // 10 + /* 10 */ 10; -//I: This one is really annoying? Where's the visual label? +/*I: This one is really annoying? Where's the visual label?*/ let defOptional /* a::a=10 */ a::a=10 @@ -185,10 +180,10 @@ let defOptional b::b=10 /* () => */ () => - // 10 + /* 10 */ 10; -//J +/*J*/ let defOptionalAlias /* a::aa=10 */ a::aa=10 @@ -196,10 +191,10 @@ let defOptionalAlias b::bb=10 /* () => */ () => - // 10; + /* 10; */ 10; -//K +/*K*/ let defOptionalAnnot /* a::(a:int)=10 */ a::(a: int)=10 @@ -207,10 +202,10 @@ let defOptionalAnnot b::(b: int)=10 /* () => */ () => - // 10; + /* 10; */ 10; -//L +/*L*/ let defOptionalAliasAnnot /* a::(aa:int)=10 */ a::(aa: int)=10 @@ -218,10 +213,10 @@ let defOptionalAliasAnnot b::(bb: int)=10 /* () => */ () => - // 10; + /* 10; */ 10; -// Invoking them +/* Invoking them */ named /* a::a */ a::a /* b::b; */ b::b; named /* a::a */ a::a /* b::b; */ b::b; @@ -231,7 +226,7 @@ optional /* a::a */ a::a /* b::b; */ b::b; optional /* a::a */ a::a /* b::b; */ b::b; let explictlyPassed = - // optional + /* optional */ optional /* a::? */ /* None */ @@ -243,7 +238,7 @@ let explictlyPassed = let a = None; let explictlyPassed = - // optional + /* optional */ optional /* a::? */ a::?a @@ -256,7 +251,7 @@ let complex_default x => 3; let myList = - //CommentAfterEqualBeforeList + /*CommentAfterEqualBeforeList */ [1, 2, 3]; let myList = [ @@ -291,7 +286,7 @@ let myList = [ 1, 2, 3 - //CommentAfterThreeBeforeCons + /*CommentAfterThreeBeforeCons */ ]; let myList = [ @@ -325,7 +320,7 @@ type hasABunch = { fieldFour: nameAge }; -// Comment at bottom of record type def +/* Comment at bottom of record type def */ type functionsInARecord = { adder: int => int, minuser: int => int @@ -340,7 +335,7 @@ let myFunctionsInARecordThatMustWrap = { /* Desired wrapping */ adder: fun reallyLongArgument => reallyLongArgument, minuser: fun anotherReallyLongArgument => anotherReallyLongArgument - // Comment at bottom of record + /* Comment at bottom of record */ }; type twoArgFunctionsInARecord = { @@ -396,7 +391,7 @@ let secondArgShouldWrap (a, b, c, d, e, f, g, h) => pointLess + a + b + c + d + e; -// Now check that one and two args both indent the same when applying +/* Now check that one and two args both indent the same when applying */ let reallyReallyLongVarName = "hello"; let result = oneArgShouldWrapToAlignWith reallyReallyLongVarName; @@ -524,7 +519,7 @@ type sixteenTuple = ( int ); -// Nothing annotated +/* Nothing annotated */ let echoTuple ( a, @@ -562,7 +557,7 @@ let echoTuple p ); -// Nothing annotated fun +/* Nothing annotated fun */ let echoTuple ( a, @@ -604,7 +599,7 @@ let echoTheEchoer (x: sixteenTuple => sixteenTuple) :(sixteenTuple => sixteenTuple) => x; -// Nothing annotated fun, passed to func +/* Nothing annotated fun, passed to func */ echoTheEchoer ( fun ( a, @@ -643,7 +638,7 @@ echoTheEchoer ( ) ); -// Argument annotated +/* Argument annotated */ let echoTuple ( ( @@ -683,7 +678,7 @@ let echoTuple p ); -// Argument annotated fun +/* Argument annotated fun */ let echoTuple ( ( @@ -723,7 +718,7 @@ let echoTuple p ); -// Argument annotated, return type annotated +/* Argument annotated, return type annotated */ let echoTuple ( ( @@ -764,7 +759,7 @@ let echoTuple p ); -// Desired formatting if first line fits within margin +/* Desired formatting if first line fits within margin */ let makeTuple a b c d e f g h i j k l m n o p => ( a, b, @@ -784,7 +779,7 @@ let makeTuple a b c d e f g h i j k l m n o p => ( p ); -// Desired formatting if first line fits within margin (70) +/* Desired formatting if first line fits within margin (70) */ let ( a, b, @@ -805,7 +800,7 @@ let ( ) = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated version +/* Annotated version */ let ( a, b, @@ -826,7 +821,7 @@ let ( ): sixteenTuple = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated inline +/* Annotated inline */ let x: ( int, int, @@ -883,7 +878,7 @@ let ( 0 ); -// Annotated version +/* Annotated version */ let ( a, b, @@ -920,7 +915,7 @@ let ( 0 ); -// Annotated inline +/* Annotated inline */ let x: ( int, int, @@ -957,8 +952,8 @@ let x: ( 0 ); -// Desired formatting if pattern does not fit, arguments do (margin 70) -// Destructured +/* Desired formatting if pattern does not fit, arguments do (margin 70) */ +/* Destructured */ let ( axx, bxx, @@ -979,8 +974,8 @@ let ( ) = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated -// Destructured +/* Annotated */ +/* Destructured */ let ( axx, bxx, @@ -1001,9 +996,9 @@ let ( ): sixteenTuple = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated -// Destructured -// Inline +/* Annotated */ +/* Destructured */ +/* Inline */ let ( axx, bxx, @@ -1041,18 +1036,18 @@ let ( ) = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Not-Destructured +/* Not-Destructured */ let someResult = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated -// Not-Destructured +/* Annotated */ +/* Not-Destructured */ let someResult: sixteenTuple = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Annotated -// Not-Destructured -// Inline +/* Annotated */ +/* Not-Destructured */ +/* Inline */ let someResult: ( int, int, @@ -1073,7 +1068,7 @@ let someResult: ( ) = makeTuple 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0; -// Destructured +/* Destructured */ let ( axx, bxx, @@ -1110,7 +1105,7 @@ let ( 0 ); -// Annotated +/* Annotated */ let ( axx, bxx, @@ -1147,7 +1142,7 @@ let ( 0 ); -// Annotated Inline +/* Annotated Inline */ let ( axx, bxx, @@ -1201,7 +1196,7 @@ let ( 0 ); -// Not-Destructured +/* Not-Destructured */ let someResult = echoTuple ( 0, 0, @@ -1221,8 +1216,8 @@ let someResult = echoTuple ( 0 ); -// Annotated -// Not-Destructured +/* Annotated */ +/* Not-Destructured */ let someResult: sixteenTuple = echoTuple ( 0, 0, @@ -1242,8 +1237,8 @@ let someResult: sixteenTuple = echoTuple ( 0 ); -// Annotated Inline -// Not-Destructured +/* Annotated Inline */ +/* Not-Destructured */ let someResult: ( int, int, @@ -1280,8 +1275,8 @@ let someResult: ( 0 ); -// Desired formatting if neither fit on one line (margin 70) -// Destructured +/* Desired formatting if neither fit on one line (margin 70) */ +/* Destructured */ let ( axx, bxx, @@ -1318,7 +1313,7 @@ let ( oxx pxx; -// Annoted +/* Annoted */ let ( axx, bxx, @@ -1355,7 +1350,7 @@ let ( oxx pxx; -// Annoted inline +/* Annoted inline */ let ( axx, bxx, @@ -1409,7 +1404,7 @@ let ( oxx pxx; -// Not-Destructured +/* Not-Destructured */ let someResult = makeTuple axx @@ -1429,8 +1424,8 @@ let someResult = oxx pxx; -// Not-Destructured -// Annoted +/* Not-Destructured */ +/* Annoted */ let someResult: sixteenTuple = makeTuple axx @@ -1450,8 +1445,8 @@ let someResult: sixteenTuple = oxx pxx; -// Not-Destructured -// Annoted inline +/* Not-Destructured */ +/* Annoted inline */ let someResult: ( int, int, @@ -1488,8 +1483,8 @@ let someResult: ( oxx pxx; -// Desired formatting if neither fit on one line (margin 70) -// Destructured +/* Desired formatting if neither fit on one line (margin 70) */ +/* Destructured */ let ( axx, bxx, @@ -1526,8 +1521,8 @@ let ( 10 ); -// Annoted -// Destructured +/* Annoted */ +/* Destructured */ let ( axx, bxx, @@ -1564,8 +1559,8 @@ let ( 10 ); -// Annoted Inline -// Destructured +/* Annoted Inline */ +/* Destructured */ let ( axx, bxx, @@ -1619,8 +1614,8 @@ let ( 10 ); -// Desired formatting if neither fit on one line (margin 70) -// Not-Destructured +/* Desired formatting if neither fit on one line (margin 70) */ +/* Not-Destructured */ let someResult = echoTuple ( 1000, 10, @@ -1640,8 +1635,8 @@ let someResult = echoTuple ( 10 ); -// Annoted -// Not-Destructured +/* Annoted */ +/* Not-Destructured */ let someResult: sixteenTuple = echoTuple ( 1000, 10, @@ -1661,8 +1656,8 @@ let someResult: sixteenTuple = echoTuple ( 10 ); -// Annoted Inline -// Not-Destructured +/* Annoted Inline */ +/* Not-Destructured */ let someResult: ( int, int, @@ -1716,7 +1711,7 @@ let someResult: ( int, int, int - // This shouldn't be broken onto its own newline: @see ensureSingleTokenSticksToLabel + /* This shouldn't be broken onto its own newline: @see ensureSingleTokenSticksToLabel */ ) = someResult; type sevenStrings = ( @@ -1823,7 +1818,7 @@ let df_locallyAbstractFunc (type b) (input: a) => { inputIs: input - // With setting ReturnValOnSameLine + /* With setting ReturnValOnSameLine */ }; let df_locallyAbstractFuncNotSugared @@ -1943,10 +1938,10 @@ let rec mutuallyRecursiveOne x => mutuallyRecursiveTwo ( ) and mutuallyRecursiveTwo y => print_int y; -// The only downside to this is that now you can't redeclare a binding. -// let newMutualRecursionSyntax x => newMutuallyRecursiveTwo (x + x); -// let newMutuallyRecursiveTwo y => print_int y; -// +/* The only downside to this is that now you can't redeclare a binding. */ +/* let newMutualRecursionSyntax x => newMutuallyRecursiveTwo (x + x); */ +/* let newMutuallyRecursiveTwo y => print_int y; */ +/* */ type x = private int; type myType 'a 'b 'c = private ('a, 'b, 'c); @@ -1991,7 +1986,7 @@ let funcOnSomeConstructorHi (SomeConstructorHi x y) secondArg => x + y; -// With two args +/* With two args */ let funcOnSomeRecord {firstFieldInRecord, secondField} => firstFieldInRecord + secondField; @@ -2011,7 +2006,7 @@ let funcOnSomeConstructorHi let funcOnSomeRecord {firstFieldInRecord, secondField} => firstFieldInRecord + secondField; -// With two args +/* With two args */ let funcOnSomeConstructorHi (SomeConstructorHi x y) secondArg => x + y; @@ -2059,25 +2054,25 @@ type term _ = | Int of /*first var arg */ int - :// First GADT res + :/* First GADT res */ term int /* Second variant leaf of GADT */ | Float of /*second var arg */ int - :// Second GADT res + :/* Second GADT res */ term int /* Third variant leaf of GADT */ | Bool of /*third var arg */ int - :// Third GADT res + :/* Third GADT res */ term int; -// Commented colors +/* Commented colors */ type commentedTypeDef = /* * Commenting first variant member. @@ -2106,11 +2101,11 @@ type colors = let blah arg => switch arg { - // Comment before Bar - // Comment between bar/pattern + /* Comment before Bar */ + /* Comment between bar/pattern */ | Red _ => 1 - // Comment Before non-first bar - // Comment betwen bar/pattern + /* Comment Before non-first bar */ + /* Comment betwen bar/pattern */ /* These will be formatted into the wrong place * and there's nothing you can do about it because * the bar essentially doesn't exist once parsed - @@ -2127,7 +2122,6 @@ let blah = | Green _ => 1; let blahCurriedX x => -<<<<<<< 0bcab8d983cb43e7a26ab04b5c06a0781971c682 fun /* Comment before first bar */ /* Comment between first bar and OR pattern */ @@ -2137,16 +2131,6 @@ let blahCurriedX x => /* Comment before second bar */ | Black x => 0 | Green x => 0; -======= - fun // Comment before first bar - // Comment between first bar and OR pattern - | Red x - | Black x - | Green x => 1 - // Comment before second bar - | Black x => 0 - | Green x => 0; ->>>>>>> update old tests type reallyLongVariantNames = | ReallyLongVariantName of recordWithLong @@ -2259,12 +2243,12 @@ let callMeWithComments /* Comment before second arg "b" */ (b: int) :/* Comment before return type annotation "int" */int => - // Comment above return value a + b + c + /* Comment above return value a + b + c */ a + b + c; let result = - // Comment before function to invoke + /* Comment before function to invoke */ callMeWithComments /* Comment before first argument expression */ (1 + 2 + 3 + 3) @@ -2284,19 +2268,19 @@ let module BMod = { }; let module CurriedSugar (A: ASig) (B: BSig) => - // Commenting before First curried functor arg + /* Commenting before First curried functor arg */ /* If these comments aren't formatted correctly * see how functor args' locations aren't set * correclty due to the fold_left. */ - // Commenting before Second curried functor arg + /* Commenting before Second curried functor arg */ { let result = A.a + B.b; - // Comment at bottom of module expression + /* Comment at bottom of module expression */ }; let module CurriedSugarFunctorResult = - // Commenting before functor name + /* Commenting before functor name*/ CurriedSugar /* Commenting before functor arg 1 in app */ AMod @@ -2304,7 +2288,7 @@ let module CurriedSugarFunctorResult = BMod; let module CurriedSugarFunctorResultInline = - // Commenting before functor name + /* Commenting before functor name*/ CurriedSugar /* Commenting before functor arg 1 in app */ { @@ -2319,7 +2303,7 @@ let module CurriedSugarFunctorResultInline = * Commenting locations */ let commentingBeforeEqual = - //beforeEqual + /*beforeEqual*/ { name: "hello", age: 20, @@ -2327,7 +2311,7 @@ let commentingBeforeEqual = }; let commentingAfterEqual = - //afterEqual + /*afterEqual*/ { name: "hello", age: 20, @@ -2335,7 +2319,7 @@ let commentingAfterEqual = }; let commentingBeforeEqualBeforeType: - //beforeEqualBeforeType + /*beforeEqualBeforeType*/ withThreeFields = { name: "hello", age: 20, @@ -2343,7 +2327,7 @@ let commentingBeforeEqualBeforeType: }; let commentingBeforeEqualAfterType: withThreeFields = - //beforeEqualAfterType + /*beforeEqualAfterType*/ { name: "hello", age: 20, @@ -2351,7 +2335,7 @@ let commentingBeforeEqualAfterType: withThreeFields = }; let commentingAfterEqualAfterType: withThreeFields = - //afterEqual + /*afterEqual*/ { name: "hello", age: 20, @@ -2359,7 +2343,7 @@ let commentingAfterEqualAfterType: withThreeFields = }; let - //beforePattern + /*beforePattern*/ commentingBeforePattern: withThreeFields = { name: "hello", age: 20, @@ -2367,8 +2351,8 @@ let }; let - //beforePattern - //beforePattern2 + /*beforePattern*/ + /*beforePattern2 */ commentingBeforePattern2: withThreeFields = { name: "hello", age: 20, @@ -2376,8 +2360,8 @@ let }; let - //*beforePattern - //beforePattern2 + /**beforePattern*/ + /*beforePattern2 */ commentingBeforePatternSpecial: withThreeFields = { name: "hello", age: 20, @@ -2391,7 +2375,7 @@ let produceRecord /*commentBeforeArg*/ x => { }; let produceRecord x => - //commentAfterArg + /*commentAfterArg*/ { name: "hello", age: 20, @@ -2425,20 +2409,20 @@ let myPolyFuncCommentAfterArrow: fun o => o; let myPolyFuncCommentBeforeEqual: 'a .'a => 'a = - //beforeEqual + /*beforeEqual */ fun o => o; let myPolyFuncCommentAfterEqual: 'a .'a => 'a = - //afterEqual + /*afterEqual */ fun o => o; let myNonPolyFuncCommentBeforeColon: - //BeforeColon + /*BeforeColon */ 'a => 'a = fun o => o; let myNonPolyFuncCommentAfterColon: - //AfterColon + /*AfterColon */ 'a => 'a = fun o => o; @@ -2451,11 +2435,11 @@ let myNonPolyFuncCommentAfterArrow: fun o => o; let myNonPolyFuncCommentBeforeEqual: 'a => 'a = - //BeforeEqual + /*BeforeEqual */ fun o => o; let myNonPolyFuncCommentAfterEqual: 'a => 'a = - //AfterEqual + /*AfterEqual */ fun o => o; let lATCurrySugarCommentBeforeType @@ -2476,13 +2460,13 @@ let lATCurrySugarCommentBeforeArg let lATCurrySugarCommentAfterArg (type a) (input: a) => - //AfterArg + /*AfterArg */ input; let lATCurrySugarCommentAfterArrow (type a) (input: a) => - //AfterArrow + /*AfterArrow */ input; let lATNotSugaredCommentBeforeEqual @@ -2513,50 +2497,50 @@ let lATNotSugaredCommentBeforeArg let lATNotSugaredCommentAfterArg (type a) (input: a) => - //AfterArg + /*AfterArg*/ input; let lATNotSugaredCommentAfterArrow (type a) (input: a) => - //AfterArrow + /*AfterArrow*/ input; let lAtFuncAnnotatedCommentBeforeColon: type a. - //BeforeColon + /*BeforeColon*/ a => a = fun (type a) (input: a) => input; let lAtFuncAnnotatedCommentAfterColon: type a. - //AfterColon + /*AfterColon*/ a => a = fun (type a) (input: a) => input; let lAtFuncAnnotatedCommentBeforeTypeVar: type a. - //BeforeTypeVar + /*BeforeTypeVar*/ a => a = fun (type a) (input: a) => input; let lAtFuncAnnotatedCommentAfterTypeVar: type a. - //AfterTypeVar + /*AfterTypeVar*/ a => a = fun (type a) (input: a) => input; let lAtFuncAnnotatedBeforeEqual: type a. a => a = - //BeforeEqual + /*BeforeEqual*/ fun (type a) (input: a) => input; let lAtFuncAnnotatedAfterEqual: type a. a => a = - //AfterEqual + /*AfterEqual*/ fun (type a) (input: a) => input; -// Ternary wrapping comments +/* Ternary wrapping comments */ let ternaryResult = - // Before Test + /* Before Test */ something ? /* Before ifTrue */ callThisFunction withThisArg : @@ -2564,7 +2548,7 @@ let ternaryResult = thatResult; let ternaryResult = - // Before Test + /* Before Test */ something ? /* Before ifTrue */ callThisFunction withThisArg : @@ -2577,7 +2561,7 @@ let ternaryResult = let returningATernary x y => x > y ? "hi" : "by"; -//* Testing some special comment alignment features +/** Testing some special comment alignment features */ /* Comments can be written like this. No leading star is required on each line. Everything will line up just fine. diff --git a/src/reason_toolchain.ml b/src/reason_toolchain.ml index e6b021c1c..bae7437c7 100644 --- a/src/reason_toolchain.ml +++ b/src/reason_toolchain.ml @@ -197,12 +197,12 @@ module Create_parse_entrypoint (Toolchain_impl: Toolchain_spec) :Toolchain = str (* Str.string_match lets you specify a position one greater than last position *) let comment_is_last_thing_on_line = Str.string_match space_before_newline !chan_input one_greater_than_comment_end in if n < loc.loc_start.pos_cnum && comment_is_last_thing_on_line then - (original_comment_contents, is_line_comment, {loc with loc_start = {loc.loc_start with pos_cnum = n}}) + (original_comment_contents, {loc with loc_start = {loc.loc_start with pos_cnum = n}}) else - (original_comment_contents, is_line_comment, loc) - | exception Not_found -> (original_comment_contents, is_line_comment, loc) + (original_comment_contents, loc) + | exception Not_found -> (original_comment_contents, loc) in - (com, attachment_location) + (com, is_line_comment, attachment_location) else (str, is_line_comment, loc) )