Skip to content

Compile time error for nested expressions  #2

@hanneskaeufler

Description

@hanneskaeufler

My project does not compile using the coverage binary. I was able to reproduce the first problem with this code:

class Repro
  @param = 1
  CONST = 1

  def call
    chained.result(CONST * (@param + 1))
  end

  def chained
    self
  end

  def result(param)
    1
  end
end

Which results in

Syntax error in src/repro.cr:6: unterminated call

    chained.result(CONST * (@param + 1))

Looking at the generated code its obsious why:

  def call
    ::Coverage[1, 2]; #<loc:"src/repro.cr",5,0>
    chained.result(CONST * (    ::Coverage[1, 3]; #<loc:"src/repro.cr",5,0>
    @param + 1
))
  end
```crystal require "coverage/runtime" ::Coverage::File.new("spec/repro_spec.cr", "b811eaf68e9e5c1c7a2cf7a4d6fdfd80",[4, 5, 6]) ::Coverage::File.new("src/repro.cr", "acb6becf068269a564cf6832dcdb6b0f",[2, 3, 6, 6, 10, 14])# require "spec" #require of `src/repro.cr` from `spec/repro_spec.cr:2` # class Repro ::Coverage[1, 0]; # @param = 1
::Coverage[1, 1]; #<loc:"src/repro.cr",2,0>

CONST = 1

def call
::Coverage[1, 2]; #loc:"src/repro.cr",5,0
chained.result(CONST * ( ::Coverage[1, 3]; #loc:"src/repro.cr",5,0
@param + 1
))
end
def chained
::Coverage[1, 4]; #loc:"src/repro.cr",9,0
self
end
def result(param)
::Coverage[1, 5]; #loc:"src/repro.cr",13,0
1
end
end

</details>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions