Skip to content

EEx compiler should provide a warning if a block is used without <%= #10536

@halostatue

Description

@halostatue

As I described on elixir-lang-core, I had a bug that happened because my eyes slipped over the following bug:

<% if @password do %>
  Temporary password: <%= @password %>
<% else %>
  You will need to log in with your password.
<% end %>

The error is easily corrected:

<%= if @password do %>
  Temporary password: <%= @password %>
<% else %>
  You will need to log in with your password.
<% end %>

It seems to me that the EEx compiler should be able to provide a compile warning if a block is used when <% … %> is used instead of <%= … %>.

This would introduce one possible incompatibility with the current compiler:

<% somevar = for item <- list do %>
  <% if(item % 2 == 0, do: item * 2, else: item * 3) %>
<% end %>

This can be resolved by combining these into a single tag:

<% somevar = form item <- list do
  if(item % 2 == 0, do: item * 2, else: item * 3)
end %>

As requested, I’ve opened an issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions