amplify-education / python-hcl2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors parsing for loop (or maybe nested for loop)

mikeurbanski1 opened this issue · comments

When parsing this file, we get the following error:

lark.exceptions.UnexpectedToken: Unexpected token Token('__ANON_0', '\n') at line 38, column 36.
Expected one of:
	* COLON
	* STAR
	* PERCENT
	* SLASH
	* __ANON_9
	* __ANON_8
	* __ANON_6
	* QMARK
	* __ANON_5
	* MORETHAN
	* PLUS
	* __ANON_4
	* MINUS
	* __ANON_7
	* LESSTHAN

The problematic lines appear to be:

bindings_by_role = distinct(flatten([
    for name in local.real_entities
    : [
      for role, members in var.bindings
      : { name = name, role = role, members = members }
    ]
  ]))

Converting the syntax to this seems to fix it (of course, it's a third party module, so we can't actually change it):

bindings_by_role = distinct(flatten([
    for name in local.real_entities: [
      for role, members in var.bindings: { name = name, role = role, members = members }
    ]
  ]))

Note that this file also hits the multi-line ternary issue towards the bottom.

This should be fixed with #92. Let me know if you are still seeing this issue