Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

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 redef mandatory when implementing abstract features (#3228, #3213, #3218).

      So redef is 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"
            -1
              

      If debug is 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 v
              

      will 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  v
              

      And calls to feat will be replaced by calls to pre_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_contructor features (#3062), using instrinsic instead.

    • Fuzion no longer permits silently ignoring a result (#3095). If feat returns a result that is no unit or void, calling feat will cause an error:

        feat     # ignoring result causes an error
              

      we 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 ok
              
    • Chained-boolean operations like a <= b <= c are now restricted to infix operators=, <=, etc., this avoids broken code like 8 %% 5 = 3 to cause a compile time error (#3264)

  • Base library
    • New base library features

      • circular buffer (#3186)

      • buffered writer (#3269)

      • fallible effect is an abstract parent intended for effects that may fail abruptly like fault, pre- and post-conditions, panic, etc. (#3157)

    • Changes related to precondition features #3260: added contract_fault (#3184), fixed preconditions of numeric operator (#3283)-

    • Changes to the following standard library features

      • change exit(handler, code) to return unit (#3173)

      • change visibility of Random_Handler (#3265)

      • cleanup, rename foldf_list to foldf (#3240)

      • hide f16/f128 for now (#3148)

      • process, add with_out/with_err (#3146)

      • remove set from buffered.reader (#3263)

  • Parser
    • cleanup: Add Num to methods and fields related to numeric literals (#3277)

    • improve syntax error on wrong set usage. (#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.checkChoice to 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 isCalled instead of isInstantiated (#3061)

    • dfa: Use StringBuilder instead of say in showWhy (#3195)

    • fuir: move addClasses to 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
    • add regression tests (#3153, #3205, #3273)

    • add test for tail recursion #1588 (#3212)

    • for simple tests, pre-process err output to avoid common false pos errors (#3185)

    • remove skip file from test fz_cmd (#3272)

    • improve segfault handling (#3256)

    • increase stack size (#3257)

    • utf8 output on Windows: add workaround for #2586 (#3175)

    • fix trailing CR handling for windows test runs (#3236)

    • renamed dfa.mk as compile.mk (#3268)

Cheers,

--The Fuzion Team.

last changed: 2024-07-10