Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hack/h2tp: Heredoc/nowdoc parsing is broken #7445

Closed
jesseschalken opened this issue Oct 27, 2016 · 3 comments
Closed

Hack/h2tp: Heredoc/nowdoc parsing is broken #7445

jesseschalken opened this issue Oct 27, 2016 · 3 comments
Labels

Comments

@jesseschalken
Copy link
Contributor

jesseschalken commented Oct 27, 2016

The parsing of heredocs and nowdocs in Hack is broken, and this is visible in both the typechecker and h2tp.

HHVM Version

HipHop VM 3.15.2 (rel)
Compiler: tags/HHVM-3.15.2-0-g83ac3e5e3f5657be0cf4c55884044f86a7818b90
Repo schema: 608339137764e8365964a1adaa7a27d125b6076f

1. Hack

Standalone code, or other way to reproduce the problem

<?hh // strict

function main():void {
  echo <<<eof
hello $foo1
eof;
  // no error?

  echo "hello $foo2";
  // error: Undefined variable $foo2
}

Expected result

Hack produces a type error for both the undefined variables $foo1 and $foo2.

Actual result

An error is only produced for the reference to $foo2. The Hack parser can't see the variable $foo1 in the heredoc.

2. h2tp

Standalone code, or other way to reproduce the problem

Run h2tp on this file:

<?hh // strict

function main():void {
  echo <<<'end'
test1
end;

  $foo = 1;
  echo <<<end
test2 $foo test2
end;
}

Expected result

<?php
require_once ($GLOBALS["HACKLIB_ROOT"]);
function main() {
  echo ("test1");
  $foo = 1;
  echo ("test2 " . $foo . " test2");
}

Actual result

<?php
require_once ($GLOBALS["HACKLIB_ROOT"]);
function main() {
  echo ("'end'\ntest1\nen");
  $foo = 1;
  echo ("end\ntest2 \044foo test2\nen");
}
@jesseschalken
Copy link
Contributor Author

@ericlippert I'm thinking of trying to fix this, but is the new parser close enough to being finished that I shouldn't bother?

@ericlippert
Copy link
Contributor

Fine by me if you fix it. We're still a ways out from having the new parser ready for production. Thanks!

@lexidor
Copy link
Collaborator

lexidor commented May 27, 2020

I am going over old issues on this repository, to see which ones apply to the current versions of hhvm.

Support for h2tp was removed in 486f44a.

@lexidor lexidor closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants