<div dir="ltr">I need to think a bit about it. Perhaps stronger erl_lint is the best and perhaps not accept all keys that can be converted to literals.<div><br></div><div>This is currently valid under that assumption since simple try catch can be evaluated in compile time:</div>
<div>    #{ {a, try a catch _:_ -> b end} => 1}.<br></div><div><br></div><div>But I think it should be rejected under the "only literals" rule since we clearly mean to evaluate the expression. Otherwise I would say that all that could be literals in v3_core should be valid.</div>
<div><br></div><div>All this stems from limiting the keys to be literals only .. we wanted to limit the scope of maps in this phase. But as I said .. I need to ponder a bit about it.</div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2014-03-04 23:10 GMT+01:00 Anthony Ramine <span dir="ltr"><<a href="mailto:n.oxyde@gmail.com" target="_blank">n.oxyde@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Oh right, sys_core_fold is an optimisation.<br>
<br>
So just restrict map keys further in erl_lint?<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Anthony Ramine<br>
<br>
Le 4 mars 2014 à 22:52, Björn-Egil Dahlberg <<a href="mailto:wallentin.dahlberg@gmail.com">wallentin.dahlberg@gmail.com</a>> a écrit :<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
> This has to work without core optimizations.<br>
><br>
> Non literal keys, or those that can't be converted to literals, has to be rejected as non-valid expressions or patterns. At least in this stage of Maps dev with literals only key.<br>
><br>
><br>
><br>
><br>
> 2014-03-04 22:40 GMT+01:00 Anthony Ramine <<a href="mailto:n.oxyde@gmail.com">n.oxyde@gmail.com</a>>:<br>
> Oh wait, nevermind, that transformation can already be done in sys_core_fold. Will do that there.<br>
><br>
> --<br>
> Anthony Ramine<br>
><br>
> Le 4 mars 2014 à 22:36, Anthony Ramine <<a href="mailto:n.oxyde@gmail.com">n.oxyde@gmail.com</a>> a écrit :<br>
><br>
> > Hello Björn,<br>
> ><br>
> > So if I understand you correctly as you mentioned in one of PRs, there should be a pass sitting between v3_core and v3_kernel that would normalize such keys to variables, for example, right? Meanwhile, v3_core should just emit variables for non-literals keys until that pass exists, do we agree?<br>

> ><br>
> > Regards,<br>
> ><br>
> > --<br>
> > Anthony Ramine<br>
> ><br>
> > Le 4 mars 2014 à 09:38, Ulf Norell <<a href="mailto:ulf.norell@quviq.com">ulf.norell@quviq.com</a>> a écrit :<br>
> ><br>
> >> -module(bug).<br>
> >> f() -> #{[try a after b end] => 0}.<br>
> >><br>
> >> -module(bug).<br>
> >> f() -> ok.<br>
> >> g() -> #{fun f/0 => 0}.<br>
> >><br>
> >> -module(bug).<br>
> >> f() -> ok.<br>
> >> g() -> #{{f()} => 0}.<br>
> >><br>
> >> $ erl<br>
> >> Erlang/OTP 17 [RELEASE CANDIDATE 2] [erts-6.0] [source-a74e66a] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]<br>
> >><br>
> >> Eshell V6.0  (abort with ^G)<br>
> >> 1> c(bug).<br>
> >> Function: f/0<br>
> >> bug.erl: internal error in kernel_module;<br>
> >> crash reason: function_clause<br>
> >><br>
> >>  in function  v3_kernel:map_key_clean/1<br>
> >>     called as v3_kernel:map_key_clean({k_cons,[2,{file,"bug.erl"}],{k_var,[],cor4},{k_nil,[2,{file,"bug.erl"}]}})<br>
> >>  in call from v3_kernel:map_group_pairs/2 (v3_kernel.erl, line 553)<br>
> >>  in call from v3_kernel:map_group_pairs/1 (v3_kernel.erl, line 529)<br>
> >>  in call from v3_kernel:map_split_pairs/5 (v3_kernel.erl, line 511)<br>
> >>  in call from v3_kernel:expr/3 (v3_kernel.erl, line 327)<br>
> >>  in call from v3_kernel:expr/3 (v3_kernel.erl, line 307)<br>
> >>  in call from v3_kernel:function/2 (v3_kernel.erl, line 152)<br>
> >>  in call from lists:mapfoldl/3 (lists.erl, line 1352)<br>
> >> bug.erl:2: Warning: function f/0 is unused<br>
> >> error<br>
> >><br>
> >> / Ulf<br>
> >><br>
> >> _______________________________________________<br>
> >> erlang-bugs mailing list<br>
> >> <a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
> >> <a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
> ><br>
><br>
> _______________________________________________<br>
> erlang-bugs mailing list<br>
> <a href="mailto:erlang-bugs@erlang.org">erlang-bugs@erlang.org</a><br>
> <a href="http://erlang.org/mailman/listinfo/erlang-bugs" target="_blank">http://erlang.org/mailman/listinfo/erlang-bugs</a><br>
><br>
<br>
</div></div></blockquote></div><br></div>