Skip to content

Code.Fragment.container_cursor_to_quote not working in cases that 1.17 version handled #14087

Closed
@lukaszsamson

Description

@lukaszsamson

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.2.5.4] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]

Elixir 1.18.0 (compiled with Erlang/OTP 26)

Operating system

any

Current behavior

In elixir_sense test suite there is a collection of tests checking error tolerance https://github.com/elixir-lsp/elixir_sense/blob/master/test/elixir_sense/core/metadata_builder/error_recovery_test.exs. I noticed a number of tests failing on 1.18 that pass on 1.17. I tried to fix them with the new trailing_fragment option. Out of 6 failing tests it helped only in 1 case.

code = """
        for x <- [], reduce: %{} do
          y, \
        """
Code.Fragment.container_cursor_to_quoted(code, trailing_fragment: " -> :ok\nend")
{:error, {[line: 2, column: 18], "syntax error before: ", "'end'"}}
code = """
        fn
          x when \
        """
 Code.Fragment.container_cursor_to_quoted(code, trailing_fragment: " -> :ok\nend")
{:error,
 {[line: 1, column: 1],
  "expected anonymous functions to be defined with -> inside: ", "'fn'"}}
code = """
          try do
            bar()
          catch
            x, \
          """
 Code.Fragment.container_cursor_to_quoted(code, trailing_fragment: " -> :ok\nend")
{:error, {[line: 4, column: 18], "syntax error before: ", "'end'"}}
code = """
        try do
          bar()
        catch
          x, _ when \
        """
Code.Fragment.container_cursor_to_quoted(code, trailing_fragment: " -> :ok\nend")
{:error, {[line: 4, column: 25], "syntax error before: ", "'end'"}}
code = """
        defmodule Abc do
          @type foo :: (bar, \
        """
Code.Fragment.container_cursor_to_quoted(code, trailing_fragment: " )\nend")
{:error, {[line: 2, column: 34], "syntax error before: ", "')'"}}

Expected behavior

Better parser error tolerance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions