2

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.

Abhik
  • 1,920
  • 7
  • 27
  • 50
  • Did HSL install properly via composer? – concat Aug 15 '20 at 19:01
  • I have put ignored_paths = ["vendor/*"] . can this be a reason ? – Abhik Aug 16 '20 at 10:53
  • 1
    Oh yes, that should be the cause. I'm guessing you were seeing many errors from vendor/ - you can ask a separate question to address those if you wish. – concat Aug 16 '20 at 13:58
  • Yes . Because I saw a bunch of errors. If you can add this as an answer here . I can mark this question as answered. – Abhik Aug 16 '20 at 15:23

1 Answers1

0

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.

concat
  • 3,107
  • 16
  • 30