Skip to content

Crashes on elixir_sense test suite #48

Open
@lukaszsamson

Description

@lukaszsamson

Here's a list of crashes I noticed when trying out Spitfire on elixir_sense parser tests

defmodule MyModule do
  import List

end

defmodule MyModule do
  import List
; (__cursor__())
end
     ** (RuntimeError) semicolon
     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:272: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:950: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire/while.ex:10: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:942: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:940: Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:192: anonymous fn/1 in Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:191: Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire.ex:137: Spitfire.parse/2
defmodule MyModule do
  use EnumFake
  import List
  foo()

end

defmodule MyModule do
  use EnumFake
  import List
  foo()
; (__cursor__())
end
     ** (RuntimeError) semicolon
     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:272: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:950: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire/while.ex:10: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:942: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:940: Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:192: anonymous fn/1 in Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:191: Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire.ex:137: Spitfire.parse/2
defmodule MyModule do
  import List
  var = '#{
end
     ** (CaseClauseError) no case clause matching: {:error, {[line: 4, column: 1], {~c"unexpected reserved word: ", []}, ~c"end"}, ~c"'\#{\nend\n", [{{3, 9}, ~c"single-quoted strings represent charlists. Use ~c\"\" if you indeed want a charlist or use \"\" instead"}], [{:match_op, {3, 7, nil}, :=}, {:identifier, {3, 3, ~c"var"}, :var}, {:eol, {2, 14, 1}}, {:alias, {2, 10, ~c"List"}, :List}, {:identifier, {2, 3, ~c"import"}, :import}, {:eol, {1, 22, 1}}, {:do, {1, 20, nil}}, {:alias, {1, 11, ~c"MyModule"}, :MyModule}, {:identifier, {1, 1, ~c"defmodule"}, :defmodule}]}
     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:1990: Spitfire.tokenize/2
       (spitfire 0.1.3) lib/spitfire.ex:2054: Spitfire.new/2
       (spitfire 0.1.3) lib/spitfire.ex:129: Spitfire.parse/2
defmodule MyModule do
  import List
  var = '
end
     ** (CaseClauseError) no case clause matching: {:error, {[opening_delimiter: :"'", expected_delimiter: :"'", line: 3, column: 9, end_line: 5, end_column: 1], [[109, 105, 115, 115, 105, 110, 103, 32, 116, 101, 114, 109, 105, 110, 97, 116, 111, 114, 58, 32, ~c"'"], ~c" (for string starting at line 3)"], []}, ~c"'\nend\n", [{{3, 9}, ~c"single-quoted strings represent charlists. Use ~c\"\" if you indeed want a charlist or use \"\" instead"}], [{:match_op, {3, 7, nil}, :=}, {:identifier, {3, 3, ~c"var"}, :var}, {:eol, {2, 14, 1}}, {:alias, {2, 10, ~c"List"}, :List}, {:identifier, {2, 3, ~c"import"}, :import}, {:eol, {1, 22, 1}}, {:do, {1, 20, nil}}, {:alias, {1, 11, ~c"MyModule"}, :MyModule}, {:identifier, {1, 1, ~c"defmodule"}, :defmodule}]}
     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:1990: Spitfire.tokenize/2
       (spitfire 0.1.3) lib/spitfire.ex:2054: Spitfire.new/2
       (spitfire 0.1.3) lib/spitfire.ex:129: Spitfire.parse/2

This one seems to be already reported in #26

defmodule MyModule do
  IO.inspect(
    :stderr,
    label: "label",
    limit:
  )
end

defmodule MyModule do
  IO.inspect(
    :stderr,
    label: "label",
(__cursor__())
  )
end
     ** (FunctionClauseError) no function clause matching in Spitfire.parse_kw_identifier/1

     The following arguments were given to Spitfire.parse_kw_identifier/1:

         # 1
         %{tokens: [{:"(", {5, 12, nil}}, {:")", {5, 13, nil}}, {:")", {5, 14, nil}}, {:eol, {5, 15, 1}}, {:")", {6, 3, 1}}, {:eol, {6, 4, 1}}, {:end, {7, 1, nil}}, {:eol, {7, 4, 1}}, :eof], literal_encoder: nil, errors: [], current_token: {:"(", {5, 1, nil}}, fuel: 150, peek_token: {:paren_identifier, {5, 2, ~c"__cursor__"}, :__cursor__}, nesting: 0}

     Attempted function clauses (showing 2 out of 2):

         defp parse_kw_identifier(%{current_token: {:kw_identifier, meta, token}} = parser)
         defp parse_kw_identifier(%{current_token: {:kw_identifier_unsafe, meta, tokens}} = parser)

     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:519: Spitfire.parse_kw_identifier/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:551: Spitfire.parse_bracketless_kw_list/1
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:611: anonymous fn/4 in Spitfire.parse_comma_list/4
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:602: Spitfire.parse_comma_list/4
       (spitfire 0.1.3) lib/spitfire.ex:1817: Spitfire.parse_paren_identifier/1
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:1059: Spitfire.parse_dot_expression/2
       (spitfire 0.1.3) lib/spitfire/while.ex:52: Spitfire.While.do_while/2
       (spitfire 0.1.3) lib/spitfire.ex:950: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:942: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:940: Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:192: anonymous fn/1 in Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:191: Spitfire.parse_program/1
defmodule MyModule do
  IO.inspect(
    :stderr,
    label: "label",
    limit
  )
end
     ** (FunctionClauseError) no function clause matching in Spitfire.parse_kw_identifier/1

     The following arguments were given to Spitfire.parse_kw_identifier/1:

         # 1
         %{tokens: [{:")", {6, 3, 1}}, {:eol, {6, 4, 1}}, {:end, {7, 1, nil}}, {:eol, {7, 4, 1}}, :eof], literal_encoder: nil, errors: [], current_token: {:identifier, {5, 5, ~c"limit"}, :limit}, fuel: 150, peek_token: {:eol, {5, 10, 1}}, nesting: 0}

     Attempted function clauses (showing 2 out of 2):

         defp parse_kw_identifier(%{current_token: {:kw_identifier, meta, token}} = parser)
         defp parse_kw_identifier(%{current_token: {:kw_identifier_unsafe, meta, tokens}} = parser)

     stacktrace:
       (spitfire 0.1.3) lib/spitfire.ex:519: Spitfire.parse_kw_identifier/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:551: Spitfire.parse_bracketless_kw_list/1
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:611: anonymous fn/4 in Spitfire.parse_comma_list/4
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:602: Spitfire.parse_comma_list/4
       (spitfire 0.1.3) lib/spitfire.ex:1817: Spitfire.parse_paren_identifier/1
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:1059: Spitfire.parse_dot_expression/2
       (spitfire 0.1.3) lib/spitfire/while.ex:52: Spitfire.While.do_while/2
       (spitfire 0.1.3) lib/spitfire.ex:950: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:942: anonymous fn/1 in Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:940: Spitfire.parse_do_block/2
       (spitfire 0.1.3) lib/spitfire.ex:297: Spitfire.parse_expression/6
       (spitfire 0.1.3) lib/spitfire.ex:192: anonymous fn/1 in Spitfire.parse_program/1
       (spitfire 0.1.3) lib/spitfire/while.ex:5: Spitfire.While2.recurse/3
       (spitfire 0.1.3) lib/spitfire.ex:191: Spitfire.parse_program/1

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