Permalink
Browse files

Handle compiler option warnings_as_errors

We do this in the samw way as the vanilla compiler by flagging an
error when there are warnings, but leaving them as warnings.
  • Loading branch information...
1 parent 4597cc9 commit 0e6eca5d06f99d3cefd278eb4e7ca705b499b663 @rvirding committed Apr 12, 2011
Showing with 50 additions and 19 deletions.
  1. +19 −1 README
  2. +1 −1 ebin/lfe.app
  3. +9 −0 src/ChangeLog
  4. +21 −17 src/lfe_comp.erl
View
20 README
@@ -14,11 +14,29 @@ of the function. The .beam file in ebin is for R13B.
I will try to make a better fix soon. Sorry about that.
-v0.6
+v0.7
----
+Handle compiler option warnings_as_errors.
+
+Improved ++ macro can now be used in patterns.
+
+List/binary comprehensions generate fewer unnecessary compiler
+warnings.
+
Added new example file with core macros implemented in LFE.
+New patterns with explicit constructors! We now follow the invariant
+that constructors and patterns should look the same. It is still
+possible to use old patterns but 'cons' and 'list' now as as "reserved
+words" like 'tuple' and 'binary'.
+
+Allow guards with generators in list/binary comprehensions. N.B. can
+cause unexpected behaviour with binary generators.
+
+v0.6
+----
+
Allow literal strings in binaries, both as plain values and as values
with specs, so (binary "abc" ("���" utf-8)) is valid. In the second
case the spec is applied to each character. Works with lists as well.
View
@@ -2,7 +2,7 @@
{application, lfe,
[{description, "Lisp Flavored Erlang (LFE)"},
- {vsn, "0.6.1"},
+ {vsn, "0.6.2"},
{modules, [lfe_boot,
lfe_codegen,
lfe_comp,
View
@@ -1,3 +1,12 @@
+2011-04-12 Robert Virding <rv@renat.local>
+
+ * lfe_comp.erl (erl_comp_opts, do_ok_return): Handle
+ warnings_as_errors ourselves in same way as vanilla compiler.
+
+2011-04-08 Robert Virding <rv@renat.local>
+
+ * lfe_comp.erl (when_opt): Change argument order.
+
2011-03-16 Robert Virding <rv@renat.local>
* lfe_macro.erl (expand_append): Expand ++ in such a way as to
View
@@ -34,8 +34,7 @@
%% -compile(export_all).
-import(lists, [member/2,keysearch/3,filter/2,foreach/2,
- all/2,map/2,flatmap/2,foldl/3,foldr/3,mapfoldl/3,mapfoldr/3,
- concat/1]).
+ all/2,map/2,flatmap/2,foldl/3,foldr/3,mapfoldl/3,mapfoldr/3]).
-import(ordsets, [add_element/2,is_element/2,from_list/1,union/2]).
-import(orddict, [store/3,find/2]).
@@ -263,24 +262,29 @@ erl_comp_opts(Os) ->
('E') -> false;
(dcore) -> false;
(to_core0) -> false;
+ (warnings_as_errors) -> false; %We handle this ourselves
(_) -> true %Everything else
end, [return|Os]). %Ensure return!
%% do_ok_return(State) -> {ok,Mod,...}.
%% do_error_return(State) -> {error,...} | error.
do_ok_return(#comp{lfile=Lfile,opts=Opts,ret=Ret0,warnings=Ws}=St) ->
- when_opt(fun () -> list_warnings(Lfile, Ws) end, report, Opts),
- %% Fix right return.
- Ret1 = case member(return, Opts) of
- true -> Ret0 ++ [return_errors(Lfile, Ws)];
- false -> Ret0
- end,
- list_to_tuple([ok,St#comp.mod|Ret1]).
+ case member(warnings_as_errors, Opts) andalso length(Ws) > 0 of
+ true -> do_error_return(St); %Warnings are errors!
+ false ->
+ when_opt(report, Opts, fun () -> list_warnings(Lfile, Ws) end),
+ %% Fix right return.
+ Ret1 = case member(return, Opts) of
+ true -> Ret0 ++ [return_errors(Lfile, Ws)];
+ false -> Ret0
+ end,
+ list_to_tuple([ok,St#comp.mod|Ret1])
+ end.
do_error_return(#comp{lfile=Lfile,opts=Opts,errors=Es,warnings=Ws}) ->
- when_opt(fun () -> list_errors(Lfile, Es) end, report, Opts),
- when_opt(fun () -> list_warnings(Lfile, Ws) end, report, Opts),
+ when_opt(report, Opts, fun () -> list_errors(Lfile, Es) end),
+ when_opt(report, Opts, fun () -> list_warnings(Lfile, Ws) end),
%% Fix right return.
case member(return, Opts) of
true -> {error,return_errors(Lfile, Es),return_errors(Lfile, Ws)};
@@ -309,20 +313,20 @@ list_errors(F, Es) ->
end, Es).
debug_print(Format, Args, St) ->
- when_opt(fun () -> lfe_io:format(Format, Args) end,
- debug_print, St#comp.opts).
+ when_opt(debug_print, St#comp.opts,
+ fun () -> lfe_io:format(Format, Args) end).
-%% when_opt(Fun, Option, Options) -> ok.
-%% unless_opt(Fun, Option, Options) -> ok.
+%% when_opt(Option, Options, Fun) -> ok.
+%% unless_opt(Option, Options, Fun) -> ok.
%% Vall Fun when Option is/is not a member of Options.
-when_opt(Fun, Opt, Opts) ->
+when_opt(Opt, Opts, Fun) ->
case member(Opt, Opts) of
true -> Fun();
false -> ok
end.
-%% unless_opt(Fun, Opt, Opts) ->
+%% unless_opt(Opt, Opts, Fun) ->
%% case member(Opt, Opts) of
%% true -> ok;
%% false -> Fun()

0 comments on commit 0e6eca5

Please sign in to comment.