Actually executing Hack code doesn't necessarily typecheck everything. You need to actually run a separate tool to enforce the type system, as described in the docs article linked here. When you do that, you'll get an error that looks something like this, depending on the exact version of HHVM you have:
File "shapes.php", line 10, characters 19-23:
Invalid argument (Typing[4110])
File "shapes.php", line 3, characters 41-43:
This is an int
File "shapes.php", line 10, characters 42-76:
It is incompatible with a string
Modern versions of HHVM will also yell at you if you aren't running the typechecker; I suspect you're running an older version, before we realized this was a point of confusion -- sorry!
What actually happens when you run type-incorrect code is undefined behavior. The answer by Ed Cottrell is correct for the current version of HHVM -- we do the same thing PHP does to coerce types -- but keep in mind it's undefined behavior and may change in future versions without notice.
Answer from Josh Watzman on Stack OverflowVideos
Actually executing Hack code doesn't necessarily typecheck everything. You need to actually run a separate tool to enforce the type system, as described in the docs article linked here. When you do that, you'll get an error that looks something like this, depending on the exact version of HHVM you have:
File "shapes.php", line 10, characters 19-23:
Invalid argument (Typing[4110])
File "shapes.php", line 3, characters 41-43:
This is an int
File "shapes.php", line 10, characters 42-76:
It is incompatible with a string
Modern versions of HHVM will also yell at you if you aren't running the typechecker; I suspect you're running an older version, before we realized this was a point of confusion -- sorry!
What actually happens when you run type-incorrect code is undefined behavior. The answer by Ed Cottrell is correct for the current version of HHVM -- we do the same thing PHP does to coerce types -- but keep in mind it's undefined behavior and may change in future versions without notice.
The interpreter will try to evaluate the 'y' key as a number to do the calculation.
Example:
echo 4 * '6';
// prints 24
echo 4 * '6foo';
// prints 24
echo 'foo' * 42;
// prints 0, because floatval('foo') === 0
Your situation is like the third example. floatval('this should cause an fatal error?') === 0, so the calculation is:
b['x'] +
b['y'] === 3 * 4 + 0 * 4 === 12
I did figure with symmetry and now I need to merge these 2 shapes so that this vertical outline will disappear
Is there any way to do it without drawing all over again? Or maybe can I add new layer and circle the contour outside?
» pip install shape-merge