Permalink
Switch branches/tags
Commits on Apr 26, 2018
  1. Fix using `use type` to override builtin classes

    fredemmott authored and hhvm-bot committed Apr 26, 2018
    Summary:
    The HSL includes:
    
    ```
    use InvariantViolationException as InvariantException; // oss-disable
    ```
    
    I tried to do this as `use type` in a new file, and:
    - hackc was happy with it
    - the typechecker was happy with it
    - hphpc fatalled
    
    Reviewed By: kmeht
    
    Differential Revision: D7758669
    
    fbshipit-source-id: 315f46aad8ef6548ed1df41c59223eab993c509a
  2. Discard trivia in codegen cases

    Philip Hölzenspies authored and hhvm-bot committed Apr 26, 2018
    Summary:
    We don't use trivia values during codegen so they can be discarded.
    
    Notes:
    1. we still use leading and trailing widths to extract doc comments in lowerer
    2. this is a tentative diff just to check if approach is viable - removal of trivia can be incorporated in any other smart constructor
    
    Reviewed By: jamesjwu
    
    Differential Revision: D7671164
    
    fbshipit-source-id: c6dc3adcb419ee7a98d3ff441f4b6c7fb693f01d
  3. Replace ptrSubsetOf() with operators

    swtaarrs authored and hhvm-bot committed Apr 26, 2018
    Summary:
    These are familiar enum class bitsets, and we already have operator-().
    
    Also s/m_ptrKind/m_ptr/ because that's the name we gave to the type...
    
    Reviewed By: mxw
    
    Differential Revision: D6507786
    
    fbshipit-source-id: c4b5d9df731131d5937ef2fd7bbfef4bcfa99f3f
  4. increase maximum size for the high arena

    binliu19 authored and hhvm-bot committed Apr 26, 2018
    Summary: in case 28G isn't enough to hold all the APC data
    
    Reviewed By: markw65
    
    Differential Revision: D7767469
    
    fbshipit-source-id: bcae6355bdfe787d46eb8736ea3fa5d8b5885195
  5. Use folly::ssl::init

    ngoyal authored and hhvm-bot committed Apr 26, 2018
    Summary: Use folly::ssl::init to install openssl locks.  There are no locks in 1.1.0 and this will also ensure openssl is initialized.
    
    Reviewed By: mingtaoy
    
    Differential Revision: D7760455
    
    fbshipit-source-id: d4ba905b49d9c0575fdf47dbadac97cea29462eb
  6. More fine grained representation of positioned syntax

    Philip Hölzenspies authored and hhvm-bot committed Apr 26, 2018
    Summary:
    Switch from generic representation of positioned syntax to more fine grained form:
    - syntax value that corresponds to completely missing node is represented by pair `source_text` * `offset`
    - syntax value that represents a token can store reference to a token itself
    - other syntax values are represented by pair of tokens
    
    This allows to go from record with 5 pointer sized fields per any syntax node to union that uses from 1 (tokens) to 2 (composite nodes) pointer sized fields
    
    Reviewed By: andrewjkennedy
    
    Differential Revision: D7671165
    
    fbshipit-source-id: d7a6bd3b6915d4aad4ed496236d342a054203f1e
  7. publish the work-in-progress hsl_random and hsl_time extensions

    fredemmott authored and hhvm-bot committed Apr 26, 2018
    Reviewed By: kmeht
    
    Differential Revision: D7756070
    
    fbshipit-source-id: 227b02a6844eb935a0bee441f3576c3bf6184966
  8. bump HHVM version number now we're past the branch cut

    fredemmott authored and hhvm-bot committed Apr 26, 2018
    Reviewed By: kmeht
    
    Differential Revision: D7763063
    
    fbshipit-source-id: 3c2aa302ecf2f603ef0e24c4a3c1b0f7f4c39f25
Commits on Apr 25, 2018
  1. Add PREG_FB_HACK_ARRAYS, keep PREG_HACK_ARR for BC for now

    fredemmott authored and hhvm-bot committed Apr 25, 2018
    Summary:
    - we generally avoid abbreviations for clarity
    - be consistent with JSON_FB_HACK_ARRAYS
    
    Reviewed By: kmeht
    
    Differential Revision: D7761007
    
    fbshipit-source-id: 3a472ec6eaeffa84d17879aa3049a3a26b17f09e
  2. Lexer tweak to disambiguate binop >= from type arg > followed by =

    Philip Hölzenspies authored and hhvm-bot committed Apr 25, 2018
    Summary:
    In experimenting with new syntax, like `let` statements, we've come across `>=`
    being ambiguously lexed; either it's the `>=` (greater-or-equal) token in a
    binary expression, or it's the closing angle of a generic type argument,
    followed by an assignment `=`, as in;
    
    ```
    let x : vec<int> = vec[]; /* intended */
    let y : vec<int>=vec[]; /* ambiguous */
    ```
    
    We already had this problem for `>>` (either right-shift binop or two
    consecutive closing angle brackets). Luckily, this only happens when types
    "meet" expressions. It's easy to disambiguate.
    
    Reviewed By: arun11111
    
    Differential Revision: D7584327
    
    fbshipit-source-id: 3c670cf0d44c7f2302a494f71d809276296d3e22
  3. Omit module names when pretty-printing NAST/TAST

    Jake Bailey authored and hhvm-bot committed Apr 25, 2018
    Summary:
    In {D7644282}, we omitted the AnnotatedAST functor name from AAST pretty-printing output. Since then, we have switched from using a ppx_deriving rewriter to using the ppx_deriving compiler plugin, which has made the `show` plugin aware of the name of the current module. As a result, the `Ast`, `Ast_defs`, and `Aast_defs` module names are now printed in AAST pretty-printing output. This isn't necessary--these module prefixes are not needed to disambiguate any names (except for `Cnormal`, which can be disambiguated by context).
    
    This change applies the `with_path = false` setting to the `show` configuration in `Ast`, `Ast_defs`, and `Aast_defs`. This causes them to produce the same output they did before we switched to the ppx_deriving compiler plugin, makes the TAST tests less noisy, and makes their output consistent with that of the `Aast` module (which uses the `with_path = false` setting).
    
    Reviewed By: pittsw
    
    Differential Revision: D7752638
    
    fbshipit-source-id: bdd236921cce128336a4c62ce705d73753c0a7ac
  4. Make debugger black-lists per-function

    markw65 authored and hhvm-bot committed Apr 25, 2018
    Summary:
    black-lists were per bytecode address; but we assumed that any given
    source key could only reach the bytecode addresses in the basic block
    containing that sk. Thats only true for live and profile translations
    though. In optimized translations any entry point could in theory
    reach the entire function.
    
    Rather than trying to treat optimized vs non-optimized functions
    differently, just mark entire functions as blacklisted.
    
    Reviewed By: swtaarrs
    
    Differential Revision: D7754573
    
    fbshipit-source-id: 82725e6eb37c81f6df8e38bb2977c1e47da34127
  5. Ship all the things! (3.26 OSS release)

    fredemmott authored and hhvm-bot committed Apr 25, 2018
    Summary:
    shipallthethings
    
    - enable new features
    - turn on stuff that was opt-in in 3.25 and we said would be always-on in 3.26
    
    This includes:
    - nonnull
    - dynamic type
    - no_namespace_fallback
    - unpacking_check_arity
    - disallow_refs_in_array
    - disallow_untyped_lambda_as_non_function
    
    Reviewed By: kmeht
    
    Differential Revision: D7731843
    
    fbshipit-source-id: 43c4a2ac023fec4a1da811522a944328fdbeaa95
  6. Fix compilation error (numa_node_set undefined) for non-NUMA builds

    kristapsk authored and hhvm-bot committed Apr 25, 2018
    Summary:
    Fixes compilation error for non-NUMA builds which was introduced with afa3f08.
    Closes #8170
    
    Differential Revision: D7534916
    
    Pulled By: fredemmott
    
    fbshipit-source-id: 2a8f878b4284753fdf0c6f3f08a4f5bac21ae943
  7. Run CST search across the codebase in parallel

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary: Leverage the files that Hack knows about, and its workers, to run a CST search across the codebase in parallel. This is done with `hh --cst-search`, and passing the JSON pattern on stdin.
    
    Differential Revision: D7749773
    
    fbshipit-source-id: c6428e5c66f064e25742f20efe2583ba012af733
  8. Use snake_case everywhere

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary:
    Currently, we're using a mixture of snake_case, lowerCamelCase, and dash-case in different situations. It's probably best to use only a single one of those styles, so as to avoid confusing the consumers of the API.
    
    I chose snake_case because it already has precedence, given the JSON output of the full-fidelity parser, and it's also usable for identifiers in code (unlike dash-case in Hack or Flow).
    
    Differential Revision: D7717960
    
    fbshipit-source-id: 4c5a5b75d1267d75980ccdafbfe6cace1c371f8c
  9. Add unit tests

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary: Add unit tests corresponding to the behavior I've been testing by hand up until now.
    
    Differential Revision: D7717579
    
    fbshipit-source-id: f787c878d9b67d77dcca3ba2c7546beed3fa8ff2
  10. Print output as JSON for `hh_single_type_check`

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary: Print results out as JSON. For now, we're only printing out a single result, for `hh_single_type_check`. In the future, we would have to print entire responses, which include the results for multiple files.
    
    Reviewed By: pittsw
    
    Differential Revision: D7703292
    
    fbshipit-source-id: 503062acb8964d390f1919b26e6d2c72d5aba0c6
  11. Parse JSON input

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary: Parses JSON input for the three selectors we have right now.
    
    Reviewed By: pittsw
    
    Differential Revision: D7701877
    
    fbshipit-source-id: c69ebd79ee2b87ba4f9b577d1a384f8d6c7f0dbd
  12. Expose `keytrace_to_string` in `Hh_json`, and make more readable

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary:
    Expose this in the case that we want to construct custom error messages for a certain keytrace.
    
    This also improves the printing. Previously, it would wrap each key in square brackets, and the keys would be in reverse order, which is not an intuitive way of representing a keytrace through a JSON object.
    
    Reviewed By: pittsw
    
    Differential Revision: D7698999
    
    fbshipit-source-id: e13ce89f1b41a822492843d059b8d6496b8f37ad
  13. Introduce basic CST search feature

    arxanas authored and hhvm-bot committed Apr 25, 2018
    Summary: This feature will let us run queries over the concrete syntax trees (CSTs) of either files provided to us, or on the entire codebase. We can use this to run large-scale codemods without having to process the CSTs in Hack-land.
    
    Reviewed By: ljw1004
    
    Differential Revision: D7656997
    
    fbshipit-source-id: 116a84654f16d929f84d5c553f7f94179de6f86c
  14. Ensure original text is removed

    Philip Hölzenspies authored and hhvm-bot committed Apr 25, 2018
    Summary: rearrange the code to make sure original source text is collected after lowering
    
    Reviewed By: jamesjwu
    
    Differential Revision: D7671163
    
    fbshipit-source-id: def6096f0f81bda37fd0ac7d44cf28b21bd343a6
  15. Don't send worker status to master for exit code 1

    fishythefish authored and hhvm-bot committed Apr 25, 2018
    Summary:
    When a flow server or flow check ends, we were seeing a bunch
    of exceptions from the worker masters about trying to write to a broken
    pipe. This diff fixes those errors.
    
    It turns out, on unix systems, a broken pipe looks like a readable fd,
    but when you read it you only get 0 bytes. Since we always read on the
    worker slave, we need to fork before we realize that the pipe is broken.
    The slave then exits with code 1. The worker master should not try to
    send this status the master process, since the master is dead.
    
    Reviewed By: alexchow
    
    Differential Revision: D7727316
    
    fbshipit-source-id: ea1942e84fedc0786ede7178967843ffe0f6f670
  16. Make doc block finding fall back to interface for autocomplete.

    pittsw authored and hhvm-bot committed Apr 25, 2018
    Summary:
    When hovering/autocompleting a class member that doesn't have a doc block, we should fall back to the doc block on the interface that declares that member, if there is one.
    
    This change will make autocomplete fall back to interfaces.
    
    From `AllPocketMonsterTrainerItemsEntQuery.php`:
    https://pxl.cl/cWLt
    
    Reviewed By: vassilmladenov
    
    Differential Revision: D7718515
    
    fbshipit-source-id: 1380df33f1ffd53820ca5bbb787affa8d01f584d
  17. Add hhbbc grouping for is-expression

    oulgen authored and hhvm-bot committed Apr 25, 2018
    Summary: as per title
    
    Reviewed By: markw65
    
    Differential Revision: D7751549
    
    fbshipit-source-id: ed4b5b6dea92d1fd07a3c2a6309b1452b1f7aebb
  18. Improve typing of tuples

    Sasha Manzyuk authored and hhvm-bot committed Apr 25, 2018
    Summary:
    The following code example (added below as a type-checker test):
    ```
    <?hh // strict
    
    function id<T>(T $x): T {
      return $x;
    }
    
    function apply<Ta, Tb>(Ta $x, (function(Ta): Tb) $f): Tb {
      return $f($x);
    }
    
    function test(bool $x): (arraykey, int) {
      return apply(
        $x,
        $x ==> {
          if ($x) {
            return tuple(42, 1);
          }
          return tuple(id('foo'), 2);
        },
      );
    }
    ```
    fails to type-check with:
    ```
    File "/home/manzyuk/fbsource/fbcode/hphp/hack/test/typecheck/tuple_union.php", line 18, characters 14-32:
    Invalid return type (Typing[4110])
      File "/home/manzyuk/fbsource/fbcode/hphp/hack/test/typecheck/tuple_union.php", line 16, characters 22-23:
      This is an int
      File "/home/manzyuk/fbsource/fbcode/hphp/hack/test/typecheck/tuple_union.php", line 18, characters 23-27:
      It is incompatible with a string
    ```
    What happens here is that when typing the lambda a fresh unresolved type variable `#n[unresolved]` is introduced for the return type `Tb` and it is passed as the expected type when type-checking the body of the lambda.  Type-checking the first return statement results in the return type growing to `#n((int, int))`, and then the second return statement is type-checked with this new type.  The function `Typing.expand_expected` strips away singleton unresolved's, so we end up checking the subtyping relationship `(string, int) <: (int, int)`, which results in an error.  Note that if the call to the function `id` is removed, the example does type check.  That's because type-checking of string literals ignores the expected type.
    
    If you compare typing of tuples to typing of collections and shapes, then one thing becomes apparent: the components of a tuple type are not wrapped into unresolved; e.g., cf. the case of shapes:
    
    diffusion/FBS/browse/master/fbcode/hphp/hack/src/typing/typing.ml;829122450e0e50fd8fe0222b20e78e460f757300$2341-2347
    
    (and as a result the above example type-checks if tuples are replaced with shapes with two known fixed fields).  Hence the suggested fix in this diff.
    
    Reviewed By: jamesjwu
    
    Differential Revision: D7728975
    
    fbshipit-source-id: 86c146788e8d879c8acefd964ee4c1537615034c
  19. Improve unification of #n with ?#n

    Sasha Manzyuk authored and hhvm-bot committed Apr 25, 2018
    Summary:
    I've just realized that when unifying `#n` with `?#n`, we forget the type `#n` was previously bound to and rebind it to `?#m` where `#m` is a fresh unresolved type.  I was able to come up with an example (added below as a test case) that exposes this problem:
    ```
    <?hh // strict
    
    function my_compact<T>(Vector<?T> $vector): Vector<T> {
      //UNSAFE
    }
    
    function test(bool $b): ?string {
    
      $nullable = Vector { 42, null };
      $non_nullable = my_compact($nullable);
    
      if ($b) {
        $res = $nullable;
      } else {
        $res = $non_nullable;
      }
    
      return $res[0];
    }
    ```
    This type checks.  Sticking `hh_show()` suggests that the type of `$nullable` is inferred as `Vector<^(int | ?^_)>`, the type of `$non_nullable` is inferred as `Vector<^(int)>`, whereas the type of `$res` is inferred as `^(Vector<^?^[unresolved]>)`.  That `^[unresolved]` allows the type of `$res` to grow when it is compared against the expected return type `?string`.
    
    The fix is similar to what I previously suggested for unification of `#n` with an unresolved containing `#n`: bind `#n` to `?#m(t)` where `t` is the type originally bound to `#n`.
    
    Reviewed By: CatherineGasnier
    
    Differential Revision: D7707562
    
    fbshipit-source-id: 54e72565e8ffb71d8afa80abd76fbb3bd29b2ada
  20. Fix the recent fix of unification of Tvar's

    Sasha Manzyuk authored and hhvm-bot committed Apr 25, 2018
    Summary: I fixed unification of `Tvar`s in D7653566 but made a mistake: when solving unification of `#n : t` with `(#n | t1 | t2 | ... | tk)`, we were supposed to introduce a fresh variable `#m`, bind it to the singleton unresolved `(t)`, and bind `#n` to `(#m | t1 | t2 | ... | tk)`.  Instead the code bound `#n` to `((t) | t1 | t2 | ... | tk)`.  Not sure if this //really// matters because in the former, correct case `#m` occurs only under the unresolved bound to `#n` and so probably cannot grow independently, but for consistency I've chosen to bring the code with agreement with the comments.
    
    Differential Revision: D7686261
    
    fbshipit-source-id: ec789c4a0cb5e4b63356d89e3669d8bcdff3b8f4
  21. Allow string as well as int for LSP diagnostic code

    ljw1004 authored and hhvm-bot committed Apr 25, 2018
    Summary: The LSP spec says that a diagnostic code can be `number | string | null`. Hack only used numbers. But as I write Flow, I think I'd like to use strings as well. This diff adds them.
    
    Reviewed By: arxanas
    
    Differential Revision: D7644142
    
    fbshipit-source-id: 7b2fe505c0a6c58d43b516077ac95d66cc0e4f3b
  22. LSP supports hover

    ljw1004 authored and hhvm-bot committed Apr 25, 2018
    Summary:
    This diff adds support for `textDocument/hover` to flow LSP.
    
    Also, since I first wrote hover for Hack, the LSP spec has been clarified to show that "null" is now the expected return value when an LSP server has no answers to give.
    
    Microsoft/language-server-protocol#261
    
    I've already added support for that into Nuclide:
    
    facebook/nuclide@67e0b1d
    
    This diff of course makes Flow return null in that case, and also changes Hack to do the same. (Obviously these Hack+Flow changes can't land until the next release of Nuclide).
    
    Reviewed By: pittsw
    
    Differential Revision: D7365284
    
    fbshipit-source-id: 7bf48a3ce279e8535999554180f433773605cf45
  23. Delete String_sequence, guess buffer size to avoid reallocations

    Philip Hölzenspies authored and hhvm-bot committed Apr 25, 2018
    Summary:
    We have `String_sequence` type for efficient prepending/appending of the text but we've never actually used this aspect of it - in all cases we first constructed `String_sequence` value and then immediately print it. This diff removes `String_sequence` and replaces its usages with buffer - as a result it reduces amount of intermediate allocations during printing step.
    Also this diff pre-allocates the buffer for the printing result to avoid repeated reallocations in case of large files
    
    Reviewed By: andrewjkennedy
    
    Differential Revision: D7671166
    
    fbshipit-source-id: c96ca1a59fefd22624e6bfcd93c3bc9cba12f7aa
  24. Add X macros for HHBBC groups

    oulgen authored and hhvm-bot committed Apr 25, 2018
    Summary: as per title
    
    Reviewed By: markw65
    
    Differential Revision: D7751370
    
    fbshipit-source-id: f5ffb7a2622a7acd8573632e96c14d15bbf95b69
  25. Worker_oomed also logged as is_oom

    alexchow authored and hhvm-bot committed Apr 25, 2018
    Summary: Worker_oomed also logged as is_oom
    
    Reviewed By: dabek
    
    Differential Revision: D7734421
    
    fbshipit-source-id: bec0a87d7ee051af8a304d7a96fac19877931a27
  26. Fix typed attribute checks on enums, interfaces, and traits, and add …

    vassilmladenov authored and hhvm-bot committed Apr 25, 2018
    …ReflectionEnum
    
    Reviewed By: jamesjwu
    
    Differential Revision: D7748295
    
    fbshipit-source-id: 95f02cb4b7eae4ae4573667ab669a6a529389f9e
  27. Remove redundant line information in Pos.pp

    Jake Bailey authored and hhvm-bot committed Apr 24, 2018
    Summary:
    When pretty-printing a position where the start and end lines are the same, print only the start line.
    
    For example, instead of printing `[5:13-5:22]`, after this change we will print `[5:13-22]`.
    
    Reviewed By: pittsw
    
    Differential Revision: D7644656
    
    fbshipit-source-id: a41bf55a1c9e988737c9672e23d74f3f746db9de