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

False Positive Syntax Error When Accessing Imports Across Modules #52

Open
scmacoll opened this issue Jan 20, 2025 · 0 comments
Open

False Positive Syntax Error When Accessing Imports Across Modules #52

scmacoll opened this issue Jan 20, 2025 · 0 comments

Comments

@scmacoll
Copy link

First of all thank you for developing this plugin, I hope to contribute to the project myself in the future.


The IntelliJ Gleam plugin reports false-positive syntax errors when:

  1. Using tuple shorthand (#()) in a list.
  2. Accessing functions or constructors (e.g., StringValue) from an imported module.

This issue does not occur when the code is contained within a single module, suggesting that the problem lies in the plugin's handling of imports and module resolution.


Reproducible Example

model/property_graph.gleam

import gleam/dict

pub type PropertyValue {
  StringValue(String)
}

pub fn create_node(
  id: String,
  node_type: String,
  properties: List(#(String, PropertyValue))
) -> Node {
  Node(
    id: id,
    node_type: node_type,
    properties: dict.from_list(properties),
  )
}

pub type Node {
  Node(
    id: String,
    node_type: String,
    properties: dict.Dict(String, PropertyValue),
  )
}

main.gleam

import model/property_graph

pub fn main() {
  let node = property_graph.create_node(
    "router_1",
    "Router",
    [#("status", property_graph.StringValue("active"))]
  )
}

Observed Behaviour

  • In the main.gleam file, the IntelliJ Gleam plugin reports the following syntax error at:

    [#("status", property_graph.StringValue("active"))]

    Error: '..' expected, got '"'.

  • Important Detail: If the code from both files is combined into a single module (i.e., everything in main.gleam), the error does not occur. This suggests that the plugin struggles with resolving imports and handling module separation.


Expected Behaviour

The code compiles and runs successfully with the Gleam compiler (gleam build and gleam run). No syntax errors should be reported by the IntelliJ Gleam plugin, regardless of whether the code is split across multiple modules.


Environment

  • IntelliJ version: IntelliJ IDEA 2024.1.7 (Ultimate Edition), Runtime version: 17.0.12+1-b1207.37 aarch64
  • IntelliJ Gleam plugin version: 0.2.1
  • Operating system: macOS Sequoia Version 15.1.1

Steps to Reproduce

  1. Create the two files as described above: model/property_graph.gleam and main.gleam.
  2. Open the project in IntelliJ with the Gleam plugin installed.
  3. Observe the syntax error reported in the main.gleam file when calling property_graph.create_node.

Additional Notes

  • Moving all the code into the main.gleam file resolves the error, confirming the issue is specific to module resolution.
  • The Gleam compiler and Emacs Gleam LSP process the code correctly in all cases, confirming that the syntax and logic are valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant