From 7c1209f3c989bc59b0a4618fb3b307e7343f97fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20=C5=9Awi=C4=85tkowski?= Date: Thu, 5 Mar 2026 21:26:24 +0100 Subject: [PATCH] fix: don't crash on unclosed brace in tuple inside map inside anonymous function --- lib/spitfire.ex | 4 ++++ test/spitfire_test.exs | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/spitfire.ex b/lib/spitfire.ex index 8c8942e..118a7d6 100644 --- a/lib/spitfire.ex +++ b/lib/spitfire.ex @@ -3804,6 +3804,10 @@ defmodule Spitfire do :eof end + defp peek_token(%{peek_token: nil}) do + :eof + end + defp peek_token(%{tokens: :eot}) do :eof end diff --git a/test/spitfire_test.exs b/test/spitfire_test.exs index a0b921d..cb6f749 100644 --- a/test/spitfire_test.exs +++ b/test/spitfire_test.exs @@ -2439,6 +2439,11 @@ defmodule SpitfireTest do ], [1]}, :ok ]}, [{[line: 1, column: 1], "missing closing brace for tuple"}]} + + code = "fn x -> %{a: {1," + + assert {:error, _ast, errors} = Spitfire.parse(code) + assert {[line: 1, column: 14], "missing closing brace for tuple"} in errors end test "missing closing map brace" do