You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inside a macro expresion, next and break cannot be used inside while and until, simply because these loops also aren't supported yet (see #10959). But there are also next and break inside blocks:
{%
(0..10).each do |i|
p i
breakif i >=5# Error: can't execute Break in a macroend%}
{%# normal refactor
ssl_version =nilCrystal::LIBRARY_PATH.split(';').each do |dir|
config_path ="#{dir.id}\\openssl_VERSION"if config_version = read_file?(config_path)
ssl_version = config_version.chomp
breakendend# `break` with value
ssl_version =Crystal::LIBRARY_PATH.split(';').each do |dir|
config_path ="#{dir.id}\\openssl_VERSION"if config_version = read_file?(config_path)
break config_version.chomp
endend%}
It is always unambiguous whether a given next or break is associated with a block or a while, and these keywords inside blocks cannot introduce any more macro infinite loops than we already have right now, unlike #10959. There is also the macro for, which one might argue should also support next and break, but for isn't impacted since it cannot appear inside a macro block. So I believe there are no blockers here and we could implement those keywords straight away.
The text was updated successfully, but these errors were encountered:
Inside a macro expresion,
next
andbreak
cannot be used insidewhile
anduntil
, simply because these loops also aren't supported yet (see #10959). But there are alsonext
andbreak
inside blocks:It would allow us to rewrite this:
crystal/src/openssl/lib_ssl.cr
Lines 11 to 19 in 9574750
into one of the following:
It is always unambiguous whether a given
next
orbreak
is associated with a block or awhile
, and these keywords inside blocks cannot introduce any more macro infinite loops than we already have right now, unlike #10959. There is also the macrofor
, which one might argue should also supportnext
andbreak
, butfor
isn't impacted since it cannot appear inside a macro block. So I believe there are no blockers here and we could implement those keywords straight away.The text was updated successfully, but these errors were encountered: