diff --git a/CHANGELOG.md b/CHANGELOG.md index 1360e22..62fd2e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased + +## [v0.4.0] - 2025-12-06 + +### Changed +- Upgrade to Luerl 1.5.1 + +### Fixed +- Warnings on Elixir 1.19 + ## [v0.3.0] - 2025-06-09 ### Added diff --git a/guides/working-with-lua.livemd b/guides/working-with-lua.livemd index bfa9a6e..b8fba86 100644 --- a/guides/working-with-lua.livemd +++ b/guides/working-with-lua.livemd @@ -4,7 +4,7 @@ ```elixir Mix.install([ - {:lua, "~> 0.3.0"} + {:lua, "~> 0.4.0"} ]) ``` diff --git a/lib/lua.ex b/lib/lua.ex index 33ca5fd..a5460b8 100644 --- a/lib/lua.ex +++ b/lib/lua.ex @@ -90,7 +90,7 @@ defmodule Lua do end chunk = - case :luerl_comp.string(String.to_charlist(code), [:return]) do + case :luerl_comp.string(code, [:return]) do {:ok, chunk} -> %Lua.Chunk{instructions: chunk} {:error, error, _warnings} -> raise Lua.CompilerException, error end @@ -283,7 +283,6 @@ defmodule Lua do end end - defp illegal_index([:_G | keys]), do: illegal_index(keys) defp illegal_index(["_G" | keys]), do: illegal_index(keys) defp illegal_index(keys) do @@ -367,10 +366,6 @@ defmodule Lua do def eval!(%__MODULE__{state: state} = lua, script, opts) when is_binary(script) do opts = Keyword.validate!(opts, decode: true) - # Luerl does some weird things with UTF8 encoding - # when its a binary see https://github.com/rvirding/luerl/issues/197 - script = String.to_charlist(script) - func = if opts[:decode] do &:luerl.do_dec/2 @@ -449,8 +444,6 @@ defmodule Lua do """ def parse_chunk(code) do - code = String.to_charlist(code) - case :luerl_comp.string(code, [:return]) do {:ok, chunk} -> {:ok, %Lua.Chunk{instructions: chunk}} diff --git a/mix.exs b/mix.exs index 2df7b63..fde66bf 100644 --- a/mix.exs +++ b/mix.exs @@ -2,7 +2,7 @@ defmodule Lua.MixProject do use Mix.Project @url "https://github.com/tv-labs/lua" - @version "0.3.0" + @version "0.4.0" def project do [ @@ -55,7 +55,7 @@ defmodule Lua.MixProject do # Run "mix help deps" to learn about dependencies. defp deps do [ - {:luerl, "~> 1.4.1"}, + {:luerl, "~> 1.5.1"}, {:ex_doc, "~> 0.38", only: :dev, runtime: false}, {:dialyxir, "~> 1.4", only: [:dev, :test], runtime: false} ] diff --git a/mix.lock b/mix.lock index 0f36d7b..82b2e96 100644 --- a/mix.lock +++ b/mix.lock @@ -1,9 +1,9 @@ %{ - "dialyxir": {:hex, :dialyxir, "1.4.5", "ca1571ac18e0f88d4ab245f0b60fa31ff1b12cbae2b11bd25d207f865e8ae78a", [:mix], [{:erlex, ">= 0.2.7", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b0fb08bb8107c750db5c0b324fa2df5ceaa0f9307690ee3c1f6ba5b9eb5d35c3"}, + "dialyxir": {:hex, :dialyxir, "1.4.7", "dda948fcee52962e4b6c5b4b16b2d8fa7d50d8645bbae8b8685c3f9ecb7f5f4d", [:mix], [{:erlex, ">= 0.2.8", [hex: :erlex, repo: "hexpm", optional: false]}], "hexpm", "b34527202e6eb8cee198efec110996c25c5898f43a4094df157f8d28f27d9efe"}, "earmark_parser": {:hex, :earmark_parser, "1.4.44", "f20830dd6b5c77afe2b063777ddbbff09f9759396500cdbe7523efd58d7a339c", [:mix], [], "hexpm", "4778ac752b4701a5599215f7030989c989ffdc4f6df457c5f36938cc2d2a2750"}, - "erlex": {:hex, :erlex, "0.2.7", "810e8725f96ab74d17aac676e748627a07bc87eb950d2b83acd29dc047a30595", [:mix], [], "hexpm", "3ed95f79d1a844c3f6bf0cea61e0d5612a42ce56da9c03f01df538685365efb0"}, - "ex_doc": {:hex, :ex_doc, "0.38.1", "bae0a0bd5b5925b1caef4987e3470902d072d03347114ffe03a55dbe206dd4c2", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "754636236d191b895e1e4de2ebb504c057fe1995fdfdd92e9d75c4b05633008b"}, - "luerl": {:hex, :luerl, "1.4.1", "0018b5002849a3ba401bc2dc5a67e45de4c404aacfd1b9d3c2fc50fde599ff12", [:rebar3], [], "hexpm", "618ff8967d23d8f8d5800a3784625aeafba7fa42648fd9af4f05fcd1383cb860"}, + "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, + "ex_doc": {:hex, :ex_doc, "0.39.2", "da5549bbce34c5fb0811f829f9f6b7a13d5607b222631d9e989447096f295c57", [:mix], [{:earmark_parser, "~> 1.4.44", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "62665526a88c207653dbcee2aac66c2c229d7c18a70ca4ffc7f74f9e01324daa"}, + "luerl": {:hex, :luerl, "1.5.1", "f6700420950fc6889137e7a0c11c4a8467dea04a8c23f707a40d83566d14e786", [:rebar3], [], "hexpm", "abf88d849baa0d5dca93b245a8688d4de2ee3d588159bb2faf51e15946509390"}, "makeup": {:hex, :makeup, "1.2.1", "e90ac1c65589ef354378def3ba19d401e739ee7ee06fb47f94c687016e3713d1", [:mix], [{:nimble_parsec, "~> 1.4", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "d36484867b0bae0fea568d10131197a4c2e47056a6fbe84922bf6ba71c8d17ce"}, "makeup_elixir": {:hex, :makeup_elixir, "1.0.1", "e928a4f984e795e41e3abd27bfc09f51db16ab8ba1aebdba2b3a575437efafc2", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "7284900d412a3e5cfd97fdaed4f5ed389b8f2b4cb49efc0eb3bd10e2febf9507"}, "makeup_erlang": {:hex, :makeup_erlang, "1.0.2", "03e1804074b3aa64d5fad7aa64601ed0fb395337b982d9bcf04029d68d51b6a7", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "af33ff7ef368d5893e4a267933e7744e46ce3cf1f61e2dccf53a111ed3aa3727"}, diff --git a/test/lua_test.exs b/test/lua_test.exs index cb11d70..9face22 100644 --- a/test/lua_test.exs +++ b/test/lua_test.exs @@ -47,7 +47,7 @@ defmodule LuaTest do message = """ Failed to compile Lua! - Failed to tokenize: illegal token on line 1: \"hi) + Line 1: syntax error near '\"' """ assert_raise Lua.CompilerException, message, fn -> @@ -121,8 +121,7 @@ defmodule LuaTest do error = """ Failed to compile Lua! - Failed to tokenize: illegal token on line 1: ' - + Line 1: syntax error near ''' """ assert_raise Lua.CompilerException, error, fn -> @@ -666,8 +665,7 @@ defmodule LuaTest do error = """ Failed to compile Lua! - Failed to tokenize: illegal token on line 1: ") - + Line 1: syntax error near '\"' """ assert_raise Lua.CompilerException, error, fn -> @@ -679,8 +677,7 @@ defmodule LuaTest do error = """ Failed to compile Lua! - Failed to tokenize: illegal token on line 1: "yuup) - + Line 1: syntax error near '\"' """ assert_raise Lua.CompilerException, error, fn ->