{"action":"created","issue":{"url":"https://api.github.com/repos/hashicorp/hcl2/issues/15","repository_url":"https://api.github.com/repos/hashicorp/hcl2","labels_url":"https://api.github.com/repos/hashicorp/hcl2/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/hcl2/issues/15/comments","events_url":"https://api.github.com/repos/hashicorp/hcl2/issues/15/events","html_url":"https://github.com/hashicorp/hcl2/issues/15","id":301946125,"number":15,"title":"Spurious \"Invalid character\" errors at EOF","user":{"login":"apparentlymart","id":20180,"avatar_url":"https://avatars1.githubusercontent.com/u/20180?v=4","gravatar_id":"","url":"https://api.github.com/users/apparentlymart","html_url":"https://github.com/apparentlymart","followers_url":"https://api.github.com/users/apparentlymart/followers","following_url":"https://api.github.com/users/apparentlymart/following{/other_user}","gists_url":"https://api.github.com/users/apparentlymart/gists{/gist_id}","starred_url":"https://api.github.com/users/apparentlymart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apparentlymart/subscriptions","organizations_url":"https://api.github.com/users/apparentlymart/orgs","repos_url":"https://api.github.com/users/apparentlymart/repos","events_url":"https://api.github.com/users/apparentlymart/events{/privacy}","received_events_url":"https://api.github.com/users/apparentlymart/received_events","type":"User","site_admin":false},"labels":[{"id":689704785,"url":"https://api.github.com/repos/hashicorp/hcl2/labels/bug","name":"bug","color":"ee0701","default":true},{"id":838739304,"url":"https://api.github.com/repos/hashicorp/hcl2/labels/syntax/native","name":"syntax/native","color":"c5def5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-03-03T00:18:55Z","updated_at":"2018-03-03T18:30:23Z","closed_at":null,"author_association":"COLLABORATOR","body":"In [a file in the Google Cloud SQL example on Terraform Registry](https://github.com/GoogleCloudPlatform/terraform-google-sql-db/blob/688a320/variables.tf), the parser seems to be getting confused about something, since it's reporting dozens of error messages like the following (two variants seen):\r\n\r\n```\r\nError: Invalid character\r\n\r\n  on .terraform/init-from-module/root/GoogleCloudPlatform-terraform-google-sql-db-688a320/variables.tf line 136:\r\n\r\nThis character is not used within the language.\r\n```\r\n\r\n```\r\nError: Invalid character\r\n\r\n  on .terraform/init-from-module/root/GoogleCloudPlatform-terraform-google-sql-db-688a320/variables.tf line 136:\r\n\r\nThe \"`\" character is not valid. To create a multi-line string, use the\r\n\"heredoc\" syntax, like \"<<EOT\".\r\n```\r\n\r\nIn both cases, the source reference is at the end of the file and so this suggests that the parser is entering recovery mode at some earlier point and then some other parser component is getting confused and not aborting properly in that mode.\r\n\r\nThe mention of the backtick character in some of the error messages may be a clue, since backticks are used in some of the description strings. Perhaps the string parser is getting confused by those backticks.\r\n\r\n---\r\n\r\nErrors like the following are also being reported, due to the new parser no longer accepting the non-idiomatic form of unquoted block labels:\r\n\r\n```\r\nError: Attribute or block definition required\r\n\r\n  on .terraform/init-from-module/root/GoogleCloudPlatform-terraform-google-sql-db-688a320/variables.tf line 17:\r\n  17: variable project {\r\n\r\nAn attribute or block definition is required here. To define an attribute, use\r\nthe equals sign \"=\" to introduce the attribute value.\r\n\r\n\r\nError: Attribute or block definition required\r\n\r\n  on .terraform/init-from-module/root/GoogleCloudPlatform-terraform-google-sql-db-688a320/variables.tf line 22:\r\n  22: variable region {\r\n\r\nAn attribute or block definition is required here. To define an attribute, use\r\nthe equals sign \"=\" to introduce the attribute value.\r\n\r\n\r\nError: Attribute or block definition required\r\n\r\n  on .terraform/init-from-module/root/GoogleCloudPlatform-terraform-google-sql-db-688a320/variables.tf line 27:\r\n  27: variable name {\r\n\r\nAn attribute or block definition is required here. To define an attribute, use\r\nthe equals sign \"=\" to introduce the attribute value.\r\n```\r\n\r\nHowever, this particular error is also visible in that repository's `outputs.tf` file and yet it doesn't also exhibit the strange \"Invalid character\" error behavior, so possibly there is something else going on here. There are no backticks in `outputs.tf`, so that lends further credence to the idea that the backticks are triggering the weird behavior.\r\n"},"comment":{"url":"https://api.github.com/repos/hashicorp/hcl2/issues/comments/370169245","html_url":"https://github.com/hashicorp/hcl2/issues/15#issuecomment-370169245","issue_url":"https://api.github.com/repos/hashicorp/hcl2/issues/15","id":370169245,"user":{"login":"apparentlymart","id":20180,"avatar_url":"https://avatars1.githubusercontent.com/u/20180?v=4","gravatar_id":"","url":"https://api.github.com/users/apparentlymart","html_url":"https://github.com/apparentlymart","followers_url":"https://api.github.com/users/apparentlymart/followers","following_url":"https://api.github.com/users/apparentlymart/following{/other_user}","gists_url":"https://api.github.com/users/apparentlymart/gists{/gist_id}","starred_url":"https://api.github.com/users/apparentlymart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apparentlymart/subscriptions","organizations_url":"https://api.github.com/users/apparentlymart/orgs","repos_url":"https://api.github.com/users/apparentlymart/repos","events_url":"https://api.github.com/users/apparentlymart/events{/privacy}","received_events_url":"https://api.github.com/users/apparentlymart/received_events","type":"User","site_admin":false},"created_at":"2018-03-03T18:30:23Z","updated_at":"2018-03-03T18:30:23Z","author_association":"COLLABORATOR","body":"The cause of this is [a quoted percent sign](https://github.com/GoogleCloudPlatform/terraform-google-sql-db/blob/688a320/variables.tf#L63).\r\n\r\nOur new parser uses `%{` as the introducer for template control sequences, whereas previously it was interpreted literally. Our intent here is that a `%` not followed by a `{` will be treated literally, but the way that is implemented causes problems here because the `%` consumes its following `\"` in order to check that it isn't a `{`, which in turn prevents the string terminator from being detected:\r\n\r\n```\r\nError: Unterminated template string\r\n\r\n  on weird.hcl line 63, in variable \"user_host\":\r\n  63:   default     = \"%\"\r\n  64: }\r\n\r\nNo closing marker was found for the string.\r\n```\r\n\r\nUnfortunately this ends up leaving things in a broken state because the scanner thinks it is still reading an embedded template while the parser has moved on and returned back to expression parsing, causing the following tokens to make no sense.\r\n"}}
{"actor":{"display_login":"apparentlymart"}}