Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent crash on sigil_prefix and sigil_suffix (OTP 27) #83

Merged
merged 7 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ jobs:
key: rebar3-cache-for-os-${{runner.os}}-otp-${{steps.setup-beam.outputs.otp-version}}-rebar3-${{steps.setup-beam.outputs.rebar3-version}}-hash-${{hashFiles('rebar.lock')}}
- name: Compile
run: ERL_FLAGS="-enable-feature all" rebar3 compile
- name: Format check
run: ERL_FLAGS="-enable-feature all" rebar3 format --verify
#- name: Format check
# run: ERL_FLAGS="-enable-feature all" rebar3 format --verify
- name: Run tests and verifications (features not enabled)
run: rebar3 test
- name: Run tests and verifications (features enabled)
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{profiles,
[{test, [{cover_enabled, true}, {cover_opts, [verbose]}, {ct_opts, [{verbose, true}]}]}]}.

{alias, [{test, [compile, format, hank, lint, xref, dialyzer, ct, cover, ex_doc]}]}.
{alias, [{test, [compile, lint, xref, dialyzer, ct, cover, ex_doc]}]}.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should definitely write up a ticket to recover these 2 tools once they incorporate the new katana version we'll create with these changes.


%% == Dependencies and plugins ==

Expand Down
6 changes: 6 additions & 0 deletions src/ktn_dodger.erl
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,12 @@ token_to_string(var, A) ->
atom_to_list(A);
token_to_string(dot, dot) ->
".\n";
% from OTP: -type af_sigil_prefix() :: {'sigil_prefix', anno(), atom()}.
token_to_string(sigil_prefix, _Prefix) ->
"";
% from OTP: -type af_sigil_suffix() :: {'sigil_suffix', anno(), string()}.
token_to_string(sigil_suffix, _Suffix) ->
"";
token_to_string(Same, Same) ->
atom_to_list(Same).

Expand Down
18 changes: 18 additions & 0 deletions test/files/otp27.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-module(otp27).

-if(?OTP_RELEASE >= 27).

-include_lib("stdlib/include/assert.hrl").

-export([break/0]).

break() ->
_ = scan:string(~"""
This is valid code.
"""),

Fun = fun () -> ok end,
?assertMatch({ok, _}
when is_function(Fun, 0), {ok, 'no'}).

-endif.
13 changes: 13 additions & 0 deletions test/ktn_code_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

-export([parse_maybe/1, parse_maybe_else/1]).

-if(?OTP_RELEASE >= 27).

-export([parse_sigils/1]).

-endif.
-endif.

-define(EXCLUDED_FUNS, [module_info, all, test, init_per_suite, end_per_suite]).
Expand Down Expand Up @@ -153,6 +158,14 @@ parse_maybe_else(_Config) ->

ok.

-if(?OTP_RELEASE >= 27).

parse_sigils(_Config) ->
{ok, _} =
ktn_dodger:parse_file("../../lib/katana_code/test/files/otp27.erl",
[no_fail, parse_macro_definitions]).

-endif.
-endif.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
Loading