Handle references to global constants in expressions
commit2014179602d6cb244bab527921f2aac4be916d78
authorJake Bailey (Hacklang) <jakebailey@fb.com>
Thu, 28 May 2020 18:03:39 +0000 (28 11:03 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 28 May 2020 18:20:00 +0000 (28 11:20 -0700)
tree3a8400c6b1e4ba3a8b37be7f1a566230a9f7f73d
parent36a2bcf2874dd8ed1814875ebbef67e49cdd08a9
Handle references to global constants in expressions

Summary: We currently only allow a subset of literal expressions in constant initializers, ignoring everything else. We also need to handle references to global constants. This means the function which converts a node to an expression needs access to the current namespace, in order to elaborate names. This function was previously a method on `Node_`, so threading that state in might have been a bit cumbersome. Instead, this diff moves the method to be a method on `DirectDeclSmartConstructors` (as is `node_to_ty`).

Reviewed By: Wilfred

Differential Revision: D21484513

fbshipit-source-id: 7a537da74223dabea23f7f18b926b1ae44d4889b
hphp/hack/src/decl/direct_decl_smart_constructors.rs
hphp/hack/test/decl/class_const_referencing_global_const.php [new file with mode: 0644]
hphp/hack/test/decl/class_const_referencing_global_const.php.exp [new file with mode: 0644]
hphp/hack/test/decl/class_const_referencing_global_const.php.typecheck.exp [new file with mode: 0644]