Search code examples
phphacklang

HHClient throw Unbound name error for functions in HSL


I am pretty new to hacklang. I have a piece of code (copied from the HSL github page)

use namespace HH\Lib\{Vec,Dict,Keyset,Str,Math};


function main(vec<?int> $foo): vec<string> {
  return $foo
    |> Vec\filter_nulls($$)
    |> Vec\map($$, $it ==> (string) $it);
}

Filename: abc.hack My composer.json looks like

{
    "require": {
        "hhvm/hhvm-autoload": "^3.1",
        "hhvm/hsl": "^4.41"
    },
    "require-dev": {
        "hhvm/hhast": "^4.64",
        "hhvm/hacktest": "^2.2",
        "facebook/fbexpect": "^2.7"
    }
}

I have included hsl . What am I doing wrong here ? I tested with other HSL functions as well , looks like hh_client is not able to detect the HSL functions and throw Unbound name (typing): HH\Lib\Vec\filter_nulls sort of error.


Solution

  • As discussed in the comments, ignored_paths: ["vendor/*"] (ignored_paths being an hhconfig option available since 3.23) was preventing the typechecker from knowing about HSL for the OP. Generally speaking, suppressing errors in vendor isn't straightforward, and requires a bit of research to keep the necessary definitions exposed to the typechecker.