facebook / facebook/hhvm

Strange syntax error for string interpolation in attributes

Open
#4,791 5 comments 0 reactions 0 assignees View on GitHub
hack low-pri
Dominant language
C++
Stars
18.7k
Forks
3.1k
Avg merge
1h 47m
Merged PRs (30d)
2

Description

``` hack
<>
function f() { }
```

This results in a somewhat strange syntax error in HHVM (the typechecker accepts it):

`Fatal error: syntax error, unexpected '"', expecting ')'` (on the first line)

We should figure out what to do with strings like that. I don't think it makes sense to actually do interpolation, which I think is what the parser is trying to do. We could treat double-quoted strings just like single-quoted strings in that context (the inconsistency bothers me a little, but then again we do the same thing in XHP attributes), or we could just disallow double-quoted strings in that context (again, inconsistent, and causes irritation for people who want strings with lots of apostrophes).

I'm ambivalent, but this particular error definitely seems like not the right answer.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.