Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into feat-6103
Browse files Browse the repository at this point in the history
  • Loading branch information
motiz88 committed Oct 22, 2018
2 parents 60ba929 + 222a42e commit 5a9f6c4
Show file tree
Hide file tree
Showing 687 changed files with 31,624 additions and 13,055 deletions.
26 changes: 13 additions & 13 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ aliases:
- image: circleci/node:8
working_directory: ~/flow

# Saves the currently-installed opam version to a file, which we include
# in cache keys.
- &opam_version
name: Calculate opam version
command: opam --version > .circleci/opamversion

- &opam_deps
name: Install deps from opam
command: |
Expand All @@ -25,12 +31,12 @@ aliases:
- &restore_opam_cache
keys:
- opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0-{{ checksum "opam" }}
- opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0
- opam-cache-{{ arch }}-opam_1_2_2
- opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0-{{ checksum "opam" }}
- opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0
- opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}

- &save_opam_cache
key: opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0-{{ checksum "opam" }}
key: opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0-{{ checksum "opam" }}
paths:
- ~/.opam

Expand Down Expand Up @@ -64,6 +70,7 @@ jobs:
# TODO: move this to a custom docker image
name: Install deps
command: sudo apt-get update && sudo apt-get install zip
- run: *opam_version
- restore_cache: *restore_opam_cache
- run:
name: Update opam repo
Expand Down Expand Up @@ -126,27 +133,20 @@ jobs:
steps:
- attach_workspace:
at: ~/flow
- restore_cache:
keys:
- brew-cache-{{ arch }}-v2
# https://github.com/Homebrew/homebrew-core/issues/26358
- run:
name: Fix homebrew python
command: brew upgrade python
- run:
name: Install opam
command: command -v opam || brew install opam aspcud
- save_cache:
key: brew-cache-{{ arch }}-v2
paths:
- /usr/local/bin/opam
- /usr/local/bin/aspcud
- run: *opam_version
- restore_cache: *restore_opam_cache
- run:
name: Install ocaml
command: opam init --comp 4.05.0 -yn | cat
- save_cache:
key: opam-cache-{{ arch }}-opam_1_2_2-ocaml_4_05_0
key: opam-cache-{{ arch }}-opam_{{ checksum ".circleci/opamversion" }}-ocaml_4_05_0
paths:
- ~/.opam
- run:
Expand Down
151 changes: 151 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,154 @@
### 0.83.0

Likely to cause new Flow errors:
* Fixed a bug where type precision was lost at module boundaries

Notable bug fixes:
* Prevented an exponential blowup when union types flow into "maybe" (`?T`) or "optional" (essentially `T | void`) types
* Allowed `{p:T}` to be a subtype of `$Shape<{+p:T}>`

Misc:
* Fixed exception when using --traces
* Changed `--verbose` to not log while loading flowlibs by default; pass `--verbose-flowlibs` to override
* Added ability for LSP clients to cancel previously-sent commands
* Improved location of diagnostics via LSP while typing
* Fixed LSP textDocument/definition response when there are no results (prevents bogus jump-to-definition inside comments, for example)
* Limited number of errors returned via LSP to 200, to improve Nuclide and Visual Studio performance
* Fixed an exception when attempting to focus a file that Flow ignored

Library definition changes:
* Added `ResizeObserver` declarations
* Added missing `net$Server.listening` property
* Added `process.cpuUsage()`

Parser:
* Fixed `export default async function` to be a `FunctionDeclaration` not a `FunctionExpression`
* Made instance properties named 'constructor' a syntax error

### 0.82.0

Likely to cause new Flow errors:
* Removed the ability to use functions as type annotations. This ability was
originally designed to support ES3-style classes, but in practice causes
confusion and missed errors. We found that the vast majority of added errors
were detecting legitimate bugs, and the remainder could be easily updated to
ES6 classes.

New Features:
* Added worker utilization and GC profiling under the `--profile` mode.

Misc:
* Further improved performance of IDE requests on large codebases.
* Tweaked OCaml GC settings to reduce time spent collecting on workers.
* Improved performance and reliability of watchman integration.

### 0.81.0

Likely to cause new Flow errors:

* Fixed a bug which allowed refinements to incorrectly escape outside of conditional expressions.
* Plugged a hole which incorrectly allowed `this` to appear in a constructor before a `super` call in some cases.
* Some errors related to uses of `typeof` may be reported at a different location than they previously were.
* Disallowed shadowing class methods with incompatible properties of the same name.
* Made miscellaneous other bug fixes that manifest only in rare cases.
* Made module properties covariant, meaning that e.g. mutating properties on the object returned by `require()` is not allowed.

Notable bug fixes:

* Improved performance of IDE requests (e.g. autocomplete, get-def) on large codebases roughly 3x.

Misc:

* Made a number of improvements to the diffs generated by global rename.
* Changed how saved-states are loaded.
* Added additional information to error messages for missing annotations for type parameters.
* Disallowed class static properties named `prototype` or `constructor`.

Library definition changes:

* Added type definitions for pointer events.
* Updated DOM `scrollIntoView` to match latest spec.
* Updated `String.prototype.toLocaleLowerCase` and `toLocaleUpperCase` to allow optional `locale` parameter.
* Made `Object.prototype.valueOf` return `mixed` instead of `Object`.
* Removed the indexer from the `Object` libdef.
* Updated `TextDecoder` to properly accept a `BufferSource`.
* Added `MediaStreamTrackEvent` definition.
* Made `String.match` return `RegExp$matchResult`.
* Added additional constants to the `fs` module.

### 0.80.0

Likely to cause new Flow errors:
* We've changed how Flow lint severity is calculated. We used to look at every location mentioned by a lint and we'd use the lowest severity, where Off < Warn < Error. Now we just use the severity at the lint's first location. Flow suppression comments (e.g. `// $FlowFixMe`) can still suppress a lint at any mentioned location. Depending on your setup, this change may expose Flow lints which were turned off by accident. For example, a "Sketchy Null Check" lint in a file with that lint set to error would have been turned off if it also mentions a file with that lint off. Now that lint will show up as an error.
* Some libdef changes may cause a few errors. For example, `Headers.get` and `URLSearchParams.get` are now annotated to return `null | string` instead of `string` and `File.lastModifiedDate: any` was replaced with `File.lastModified: number`.

Notable bug fixes:
* Fixed a crash that could happen when a persistent connection disappears.

Misc:
* Many improvements to the libdefs and docs. Thanks for the PRs, everyone!
* Small perf improvement by making `BoundT` (internal representation of type parameter bounds) smaller.

Parser:
* Small change to the OCaml AST for the `extends` expression in a class declaration. Moved a couple of properties to their own node.

### 0.79.1

Notable bug fixes:
* If a server was not already started, running `flow status --flowconfig-name 'name'`
would start a server without taking into account the new flowconfig name. The same
is true for running flow without any command specified. This changes this by
passing the name to the new server.

### 0.79.0

Likely to cause new Flow errors:
* A fix in requiring annotations on exports: Flow uses type variables for
unannotated program parts. To facilitate inference, these type variables may
not appear in input positions of exports. Before, Flow would not complain if a
type variable appeared in *both* an output and an input position of an export
(in that order), as the first occurrence marked the use of the type variable
as legitimate. Now, Flow analyzes exports in a polarity-sensitive way and will
require an annotation in the above scenario.

New Features:
* Saved state:
- Added an initialization path, where instead of parsing every file dependency,
it loads the expected results for each available file from the saved state.
- A hash is stored for each file in the saved state to determine whether it has been
modified and therefore needs to be reparsed after the state is loaded. This way,
saved state servers can skip parsing files that are unchanged.
- If loading saved state fails, Flow falls back to a full initialization, unless
`--saved-state-no-fallback` is passed in which case Flow fails.
- Saved state tests are included in the automated testing framework.
* Profiling was refactored to support hierarchical profiling. That is:
- Support running timers inside of other timers.
- Support merging a finished profiling object (like from a recheck) into the
currently running profiling object (like from handling a command).
* Cancelable workloads (jobs that handle commands). If Flow determines that a file
has changed while handling a command, it stops, performs a recheck, and then
re-runs the workload from scratch.
* The Flow diff checker became more fine-grained, by including comparisons at the
level of loops and variable declarations.
* Added a `name` field in the `[options]` portion of `.flowconfig`.

Notable bug fixes:
* Send the server logging context to the LSP command and use that when logging
success and failure events instead of the LSP command's context (which is logged
as the client context).
* Fixed stack overflow when running `flow --json` with a large error output, by
moving to a tail-recursive implementation.
* Fixed string literal printing in `flow suggest`.

Misc:
* Library definition improvements for `React$Context.Provider` and
`CanvasRenderingContext2D.imageSmoothingQuality`.
* Typed AST: The constraint generation phase returns a version of the AST that
includes a type for each program node.
* Added doc details for `$Shape`.
* The changes in saved state were followed by code refactorings in various checking
modules (`types_js.ml`, `merge_service.ml`, `rechecker.ml`, etc.).

### 0.78.0

New Features:
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ MODULES=\
src/commands/config\
src/common\
src/common/audit\
src/common/build_id\
src/common/errors\
src/common/lints\
src/common/lwt\
Expand Down Expand Up @@ -105,6 +106,7 @@ MODULES=\
src/server/server_utils\
src/server/shmem\
src/services/autocomplete\
src/services/get_def\
src/services/inference\
src/services/inference/module\
src/services/flowFileGen\
Expand Down Expand Up @@ -144,9 +146,12 @@ NATIVE_C_FILES=\
$(INOTIFY_STUBS)\
$(FSNOTIFY_STUBS)\
src/common/xx/xx_stubs.c\
hack/heap/hh_assert.c\
hack/heap/hh_shared.c\
hack/heap/hh_shared_sqlite.c\
hack/utils/get_build_id.c\
hack/utils/sys/files.c\
hack/utils/sys/gc_profiling.c\
hack/utils/sys/getrusage.c\
hack/utils/sys/handle_stubs.c\
hack/utils/sys/nproc.c\
Expand Down Expand Up @@ -368,7 +373,7 @@ flow.odocl: $(shell find . -name "*.ml" -o -name "*.mli")
done
# For some reason these two AST files cause ocamldoc to get stuck
cat deps \
| grep -v "src/parser/ast.ml" \
| grep -v "src/parser/flow_ast.ml" \
| sed "s/\.ml$$//" > $@
rm -f deps last_deps temp_deps

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ flow init
flow check
```

More thorough documentation and many examples can be found at https://flow.org.
More thorough documentation and many examples can be found at [flow.org](https://flow.org/).

## Building Flow

Expand Down Expand Up @@ -184,7 +184,7 @@ To run a subset of the tests you can pass a second argument to the `runtests.sh`
For example: `bash runtests.sh bin/flow class | grep -v 'SKIP'`

## Join the Flow community
* Website: [https://flow.org/](https://flow.org/)
* Website: [https://flow.org](https://flow.org/)
* irc: #flowtype on Freenode
* Twitter: follow [@flowtype](https://twitter.com/flowtype) and [#flowtype](https://twitter.com/hashtag/flowtype) to keep up with the latest Flow news.
* Stack Overflow: Ask a question with the [flowtype tag](http://stackoverflow.com/questions/tagged/flowtype)
Expand Down
3 changes: 2 additions & 1 deletion _tags
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
true: package(ppx_deriving), package(dtoa), package(wtf8)
true: package(core_kernel), package(ppx_deriving), package(dtoa), package(wtf8)
<**/*.ml*>: ocaml, warn_A, warn(-4-6-29-35-44-48-50), warn_error_A, safe_string
<hack/fsnotify_win/fsnotify.ml>: unsafe_string
<hack/heap/*.ml*>: warn(-27-34)
<hack/third-party/core/result.ml>: warn(-41)
<hack/utils/*.ml*>: warn(-3-27)
<src/flowlib/flowlib.ml>: ppx(scripts/ppx_gen_flowlibs.native lib/ prelude/)
<src/parser/*.ml*>: warn(-39)
<src/common/ty/*.ml*>: package(visitors.ppx)
<**/node_modules/**>: -traverse
<_obuild>: -traverse
<packages>: -traverse
84 changes: 84 additions & 0 deletions hack/common/common.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
module List = struct
include Core_kernel.List

let rec fold_left_env env l ~init ~f = match l with
| [] -> env, init
| x :: xs ->
let env, init = f env init x in
fold_left_env env xs ~init ~f

let rev_map_env env xs ~f =
let f2 env init x =
let env, x = f env x in
env, x :: init
in
fold_left_env env xs ~init:[] ~f:f2

let map_env env xs ~f =
let rec aux env xs counter =
match xs with
| [] -> env, []
| [y1] ->
let env, z1 = f env y1 in
env, [z1]
| [y1; y2] ->
let env, z1 = f env y1 in
let env, z2 = f env y2 in
env, [z1; z2]
| [y1; y2; y3] ->
let env, z1 = f env y1 in
let env, z2 = f env y2 in
let env, z3 = f env y3 in
env, [z1; z2; z3]
| [y1; y2; y3; y4] ->
let env, z1 = f env y1 in
let env, z2 = f env y2 in
let env, z3 = f env y3 in
let env, z4 = f env y4 in
env, [z1; z2; z3; z4]
| [y1; y2; y3; y4; y5] ->
let env, z1 = f env y1 in
let env, z2 = f env y2 in
let env, z3 = f env y3 in
let env, z4 = f env y4 in
let env, z5 = f env y5 in
env, [z1; z2; z3; z4; z5]
| y1::y2::y3::y4::y5::ys ->
let env, z1 = f env y1 in
let env, z2 = f env y2 in
let env, z3 = f env y3 in
let env, z4 = f env y4 in
let env, z5 = f env y5 in
let env, zs =
if counter > 1000
then
let env, zs = rev_map_env env ys ~f in
env, rev zs
else
aux env ys (counter + 1)
in
env, z1::z2::z3::z4::z5::zs
in
aux env xs 0

let rec map2_env env l1 l2 ~f = match l1, l2 with
| [], [] -> env, []
| [], _ | _, [] -> raise @@ Invalid_argument "map2_env"
| x1 :: rl1, x2 :: rl2 ->
let env, x = f env x1 x2 in
let env, rl = map2_env env rl1 rl2 ~f in
env, x :: rl

let filter_map_env env xs ~f =
let env, l = rev_map_env env xs ~f in
env, rev_filter_map l ~f:(fun x -> x)

let rec replicate ~num x =
match num with
| 0 -> []
| n when n < 0 ->
raise @@ Invalid_argument (
Printf.sprintf "List.replicate was called with %d argument" n)
| _ -> x :: replicate ~num:(num - 1) x

end
18 changes: 18 additions & 0 deletions hack/heap/hh_assert.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the "hack" directory of this source tree.
*
*/

#include "hh_assert.h"

#define CAML_NAME_SPACE
#include <caml/callback.h>
#include <caml/fail.h>

void raise_assertion_failure(char * msg) {
caml_raise_with_string(*caml_named_value("c_assertion_failure"), msg);
}
Loading

0 comments on commit 5a9f6c4

Please sign in to comment.