Skip to content

Commit

Permalink
fix unicode bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
joshi-monster authored and lpil committed Dec 7, 2024
1 parent 56268c2 commit 323215f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@
- Fixed a bug where the inferred variant of values was not properly cached,
leading to incorrect errors on incremental builds and in the Language Server.
([Surya Rose](https://github.com/GearsDatapacks))

- Fixed a bug where Gleam would be unable to compile to BEAM bytecode if the
project path contains a non-ascii character.
([yoshi](https://github.com/joshi-monster))

## v1.6.1 - 2024-11-19

Expand Down
14 changes: 8 additions & 6 deletions compiler-cli/templates/gleam@@compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
% TODO: Don't concurrently print warnings and errors
% TODO: Some tests

main(_) -> compile_package_loop().
main(_) ->
ok = io:setopts([binary, {encoding, utf8}]),
ok = configure_logging(),
compile_package_loop().

compile_package_loop() ->
case file:read_line(standard_io) of
case io:get_line("") of
eof -> ok;
{ok, Line} ->
Line ->
Chars = unicode:characters_to_list(Line),
{ok, Tokens, _} = erl_scan:string(Chars),
{ok, {Lib, Out, Modules}} = erl_parse:parse_term(Tokens),
Expand All @@ -25,9 +28,8 @@ compile_package(Lib, Out, Modules) ->
filename:extension(Module) =:= ".ex"
end,
{ElixirModules, ErlangModules} = lists:partition(IsElixirModule, Modules),
ok = configure_logging(),
ok = add_lib_to_erlang_path(Lib),
ok = filelib:ensure_dir([Out, $/]),
ok = add_lib_to_erlang_path(Lib),
{ErlangOk, _ErlangBeams} = compile_erlang(ErlangModules, Out),
{ElixirOk, _ElixirBeams} = case ErlangOk of
true -> compile_elixir(ElixirModules, Out);
Expand Down Expand Up @@ -166,6 +168,6 @@ configure_logging() ->

log(Term) ->
case persistent_term:get(gleam_logging_enabled) of
true -> erlang:display(Term), ok;
true -> io:fwrite("~p~n", [Term]), ok;
false -> ok
end.

0 comments on commit 323215f

Please sign in to comment.