소스 검색

Fix opts check when compiler called with dict opts

rebar_base_compiler allows to be called with two types of options: a
dictionary, or a rebar_state record. In the later case, the options are
taken out with a call from rebar_opts, which fetches options that have
been inserted in the application via rebar_app_info as part of the
app_discovery phase, and are a list.

This yields a possibility that options used when formatting warnings can
either be a list of a dict, and we only used lists when making checks.
This ended up breaking 3rd party compiler users (i.e. LFE compile
plugin) since they were calling us with a dict rather than our own
internal records.

This patch supports both types of lookups to avoid issues.
pull/1280/head
Fred Hebert 9 년 전
부모
커밋
2c7296babf
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. +7
    -1
      src/rebar_base_compiler.erl

+ 7
- 1
src/rebar_base_compiler.erl 파일 보기

@ -155,7 +155,13 @@ format_warnings(Source, Warnings) ->
format_warnings(Source, Warnings, []).
format_warnings(Source, Warnings, Opts) ->
Prefix = case lists:member(warnings_as_errors, Opts) of
%% `Opts' can be passed in both as a list or a dictionary depending
%% on whether the first call to rebar_erlc_compiler was done with
%% the type `rebar_dict()' or `rebar_state:t()'.
LookupFn = if is_list(Opts) -> fun lists:member/2
; true -> fun dict:is_key/2
end,
Prefix = case LookupFn(warnings_as_errors, Opts) of
true -> "";
false -> "Warning: "
end,

불러오는 중...
취소
저장