2024-07-10: Fuzion July Update
A long list of improvements to all parts for Fuzion. Among the many minor language and library improvements the new handling of pre-conditions as effects and support for inheritance of pre-conditions of redefined features is maybe the most important one.
- Fuzion language
Make use of
redefmandatory when implementing abstract features (#3228, #3213, #3218).So
redefis required now, e.g., in this code:new_line : String is public redef utf8 => [u8 10]This avoids bugs due to accidental redefinition and underlines the fact that redefinition includes inheritance of pre- and post-conditions.
Precondition are now syntax sugar that uses effects (#3260). This permits code to handle pre-condition failures as in
v := fuzion.runtime.pre_fault .try ()-> a := i32 1000000 a*a .catch s-> say "precondition failed $s" -1If
debugis enabled, this will result in printing that the precondition of `infix *` did not hold due to the overflow caused by the code.Internally, what happens is that code with a precondition like
feat(a t) pre cc => code r := feat vwill be compiled into
feat(a t) => code pre_feat(a t) => if !cc then fuzion.runtime.pre_fault.cause "cc" pre_and_call_feat(a t) => pre_feat a feat a r := pre_and_call_feat vAnd calls to
featwill be replaced by calls topre_and_call_feat.This change resulted in a significant simplification of the Fuzion middle end and back ends, code related to pre- and post-conditions could be removed.
Precondition inheritance is now supported (#3260): Preconditions in redefined features can only be weakened.
use keyword (for/do/while/until) as reference for indentation (#3177). This avoids errors as in
for i := 0, i+1 until i > 3 do say "hey!"which used to be parsed as two loops (the second one being
do say "hey!", now causes an error.remove
intrinsic_contructorfeatures (#3062), usinginstrinsicinstead.Fuzion no longer permits silently ignoring a result (#3095). If
featreturns a result that is nounitorvoid, callingfeatwill cause an error:feat # ignoring result causes an errorwe need to use the result and have to ignore it explicitly, e.g., by
ignore := feat # assign result to a dummy field is ok _ := feat # assign result to _ is also okChained-boolean operations like
a <= b <= care now restricted to infix operators=,<=, etc., this avoids broken code like8 %% 5 = 3to cause a compile time error (#3264)
- Base library
- Parser
cleanup: Add
Numto methods and fields related to numeric literals (#3277)improve syntax error on wrong
setusage. (#3262)lexer: raise error if num literal is followed by letters. (#3258)
Fix issue parsing tuples (#3242), it is no longer required to use double parentheses in code like
f(x option ((i32,i32))) => ...which can now be written as
f(x option (i32,i32)) => ...
- Front end
fix cryptic feature names in err output (#3155)
fix reproducibility of order of parsing of source files (#3188)
Code cleanup
cleanup loop code (#3279)
Delay calls to
AbstractType.checkChoiceto the types checking phase (#3197)make error handling for types more fault tolerant (#3183)
move choiceTypeCheck from type inf to type check (#3154)
remove unique anonymous feature id (#3174)
refine lookup0 to consider the scope of definition/usage of a feature (#3112)
Bug Fixes
fix NPE in Block.checkTypes (#3226)
Fix post-condition failure on fuzion-lang.dev's
design/examples/arg_choice.fz(#3193)fix unjustified "Block must end with a result expression" (#3271)
In containsThisType: Fix check-fail on call to
outer()on type parameter (#3181)Workaround for #3160 for nested and inherited type features (#3182)
- Middle end
air: do not automatically mark ref results from intrinsics as instantiated (#3200)
air: for intrinsic constructors mark outers as instantiated as well (#3206)
air: in abstractCalled-check use
isCalledinstead ofisInstantiated(#3061)dfa: Use
StringBuilderinstead ofsayinshowWhy(#3195)fuir: move
addClassesto constructor (#3145)
- JVM back end
be/jvm/int: workaround f64
e^1.0 != e(#3239)
- C back end
fix "use of an empty initializer is a C23 extension" (#3139, #3209)
fix JAVA_HOME and jvm.dll-path on windows (#3210)
fix switch-expr in fzE_call_v0/fzE_call_s0 (#3231)
fix test process on windows (#3198)
fix void function should not return void expression (#3227)
improve c11 compat., no empty initializer (#3190)
win.c remove some includes (#3215)
- Interpreter back end
improve thread safety (#3252)
- Tests
Cheers,
--The Fuzion Team.