From 23a497af427493b94739761e4d4974e12bc67579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Tue, 9 Apr 2019 06:37:55 +0200 Subject: Issue an error for improper use of record_info/2 in a fun `record_info/2` is a pseudo-function that requires literal arguments known at compile time. Therefore, the following usage is illegal: f() -> fun record_info/2. However, `erl_lint` did not issue a compilation error for this usage, and the compiler would crash in a later pass. https://bugs.erlang.org/browse/ERL-907 --- lib/stdlib/src/erl_lint.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/stdlib/src/erl_lint.erl') diff --git a/lib/stdlib/src/erl_lint.erl b/lib/stdlib/src/erl_lint.erl index 00fd731e1d..e0c37ca030 100644 --- a/lib/stdlib/src/erl_lint.erl +++ b/lib/stdlib/src/erl_lint.erl @@ -2276,6 +2276,9 @@ expr({'fun',Line,Body}, Vt, St) -> case Body of {clauses,Cs} -> fun_clauses(Cs, Vt, St); + {function,record_info,2} -> + %% It is illegal to call record_info/2 with unknown arguments. + {[],add_error(Line, illegal_record_info, St)}; {function,F,A} -> %% BifClash - Fun expression %% N.B. Only allows BIFs here as well, NO IMPORTS!! -- cgit v1.2.3