We are starting the year with a new release with several bugfixes and improvements. Below we list the most important or interesting changes, without mentioning several bugfixes and smaller enhancements. For more details, visit the changelog. Breaking changes are marked with ⚠️.
In this release we included 152 changes since the 1.6.2 release by 38 contributors. We thank all the effort put into improving the language! ❤️
Below we list the most remarkable changes in the language, compiler and stdlib.
The REPL interface of the interpreter has received a major usability improvement. The command prompt now supports multiline input, command history, and several key bindings.
For technical reasons, the interpreter currently only ships by default in
brew. For other platforms you need to compile it from the sources with
interpreter=1 in the
Regex with PCRE2
Crystal relies on
libpcre as engine for executing regular expressions in
In 1.7.0 we’re adding support for its successor,
libpcre2, but for now it’s opt-in with the compiler flag
There are no major differences in usage and PCRE2 is mostly backwards compatible. So we don’t expect many issues. But we still encourage testing out the new engine to see if something breaks.
PCRE2 is going to be enabled implicitly in one of the next releases, likely becoming the default engine. PCRE will continue to serve as a fallback when the newer library is not available. See #12790 for the tracking issue.
The regex engine is also used in the compiler for validating regex literals. Updating the compiler to PCRE2 might cause some friction due to minor syntactical differences. Using different regex engines in the compiler and the compiled program may lead to the compiler rejecting a regex literal for syntax errors, even if it’s valid for the runtime engine. Read more about the implications on the language syntax in #12857.
- Lib functions are now visible in top-level macros (#12848).
@[Deprecated]annotation now (#12557).
- Removed oct/bin floating point literals. This number syntax had been broken and isn’t very useful anyway… (#12687).
⚠️ Obsolete FreeBSD 11 compatibility was dropped (#12612).
File.real_path was renamed to
File.realpath. This spelling just makes more sense as it’s used everywhere else. The old version is deprecated, but keeps working until the next major release (#12552).
⚠️ Error handling for
libXML2 does no longer leak errors outside the current context.
XML.errors has been deprecated, but should continue to work. We highly recommend to access errors directly in the respective context via
XML::Node#errors (#12663, #12795).
BigDecimal.new(Float32::MAX) # => 3.4028235e+38
- Automatically cast from
- Several missing
- Methods to manipulate
There were a couple of changes to improve code quality in the entire repository. Most of them are based on suggestions by the static code analyzer tool ameba. Nothing is automated yet, so we can’t ensure this for code additions. But that would one of the next steps.
A nice feature supported by many code highlighters is context-specific heredoc deliminators. We implemented that accross the code base in #12816.
html_string = <<-HTML <p>This uses HTML code highlighting!</p> HTML
This Crystal release comes with a new release of
shards: version 0.17.2.
It brings two small improvements:
- Better error message when creating a symlink fails on Windows (with a recommendation to enable developer mode).
- A program executed with
shards runnow inherits stdin (as