VladRassokhin / intellij-hcl

HCL language support for IntelliJ platform based IDEs
Apache License 2.0
244 stars 48 forks source link

Syntax issue with for expressions in latest plugin/PyCharm version #356

Closed allenhumphreys closed 2 years ago

allenhumphreys commented 2 years ago

Thank you for opening an issue. In this template paragraph text could be removed, however please retain headers.

Prerequisites

Installation details

Terraform Configuration Files

locals {
  # Ignore these behind the scenes settings
  ignored_existing_settings = ["AzureWebJobsStorage", "FUNCTIONS_EXTENSION_VERSION"]
  existing_app_settings = { for setting_name, encoded_object in data.external.existing-app-settings.result :
    setting_name => sensitive(jsondecode(encoded_object).value) if !contains(local.ignored_existing_settings, setting_name)
  }
  # App Settings we apply regardless of runtime
  common_app_settings = {
    WEBSITE_RUN_FROM_PACKAGE       = sensitive("")
    APPINSIGHTS_INSTRUMENTATIONKEY = var.app_insights_instrumentation_key

    # The webpage is bad for things that do health checks and download the entire page, like frontdoor
    AzureWebJobsDisableHomepage = "true"
  }
}

Expected Behavior

What should have happened?

Correct syntax highlighting.

Actual Behavior

What actually happened?

The plugin encounters some syntax that it can't handle, and then the rest of the file is not highlighted. It reports an error of '(', <operator> or <property> expected, got 'setting_name' but the configuration is valid.

Screen Shot 2021-09-10 at 1 35 09 PM

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Use the config above
VladRassokhin commented 2 years ago

Yeah, parser bug around expressions precedence. Will be fixed in the next plugin update. For now you could write !(contains(local....) (wrap method call with parentheses)

allenhumphreys commented 2 years ago

I had an intuition that some parenthesis somewhere might help but I didn’t try very many permutations!

Thanks for all the new updates and fixes, love the plugin a lot!

VladRassokhin commented 2 years ago

Fixed in 0.7.14