nums should be Stringish
HHVM Version
3.15.0
Standalone code, or other way to reproduce the problem
<?hh
$value = 7;
echo <input type="number" value={$value} />;
Expected result
<input type="number" value="7" />
Actual result
attribute `value` of type `integer` supplied to element `input`, expected `Stringish`.
This particular example throws a Hack error, but it's just a simplified version of what we ran into. Not having num be of type Stringish is rather annoying for this particular case (value of a number input) as it requires wrapping the variable in a string, which Hack doesn't like.
The way I see the Stringish type is that it represents a value that can be safely casted to a string. A num certainly fulfils that condition.
cc @fredemmott as we've only had this issue while using XHP and their might be something that can be done there to work around this.
XHP won't be special-casing this; consistency with Hack's type system is a goal of 2.x+.
I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.
Although Stringish hasn't been ouright removed yet. The hhvm team has been trying to get rid of it since hhvm 3.30.0, but this has taken quite a bit longer than expected.
- 3.30.0 Casting objects to strings will no longer be supported (
hhvm.fatal_on_convert_object_to_string); this includes removal of support for__toString(). - 4.19.0 The Stringish interface is deprecated, and can not be converted to a string without a typechecker error.
- 4.44 string casts of Stringish objects will change to raise a runtime exception; the
hhvm.notice_on_implicit_invoke_to_stringoption can be used to detect this. - 4.52 Runtime support for casting objects to strings via
__toStringwill be removed shortly; this includes(string) $obj,print($obj),sprintf('%s', $obj)among others. Thehhvm.notice_on_implicit_invoke_to_stringINI setting can be used to find calls that will break.
The only changes being made to Stringish are those that aid in its removal.