Skip to content

ASFv3.4.0

Choose a tag to compare

@ws-garcia ws-garcia released this 05 Nov 18:24
· 47 commits to main since this release
c4bb5b6

[v3.4.0] - 2026-11-05

https://github.com/ECP-Solutions/ASF/releases/tag/v3.4.0

Highlights

  • Added

    • Portable examples — examples/portable/ holds six ASF scripts that run unchanged in Excel, Word, PowerPoint, LibreOffice Calc, Writer and Impress: a first example and five for construction site management (a budget summary by chapter, checks of daily work reports against the budget, a monthly progress certificate, a polynomial price revision and the normalisation of item lists with regular expressions). Each script passes the open document to scripts/lib/office.vas, which finds out the application and gives the six the same API: a report is a new sheet in a spreadsheet, headings, paragraphs and a table in a text document, and slides in a presentation; spreadsheets supply the input tables, the other applications a sample project (scripts/data/project.vas). One host module per suite (hosts/OfficeHost.bas for the three Microsoft applications, hosts/LibreOfficeHost.bas for the three LibreOffice ones) only runs the scripts. tools/run_lo.py runs every script in Calc, Writer and Impress, compares what it wrote with expected/, and builds portable-examples.ods, .odt, .odp and .xlsx. The scripts use the fixes below, so they need ASF 3.3.2; ASF.oxt is version 3.3.2.
    • throw and the catch variable — throw expr raises expr, which catch (e) binds to e; catch (e) also binds the message of a runtime error. A throw that no catch handles ends the script, and ASF.LastError holds its value (or the last runtime error), so a host can tell why a script returned nothing.
    • Tools/vba_check.py — finds two VBA compile errors that the LibreOffice test run cannot see, since LibreOffice Basic compiles that code: ByRef argument type mismatch (a Variant passed to a ByRef parameter of another type, as pinfo(1) was) and Duplicate declaration in current scope. python3 Tools/vba_check.py checks src/*.cls; CONTRIBUTING.md describes it.
  • Fixed

    • Math in exported functions — a function exported by a module and called from another script could not use Math (Math.floor(x) returned nothing): a module's scope now has Math, as the program's does.
    • Methods on template literals — `${x}`.trim() ignored the call and returned the template; members and calls now chain on a template as on any string.
    • == and != with arrays and objects — comparing an array or an object with anything (m == null, o == p) raised a type mismatch, which ended the function or script without a value; != with null raised too. They now never raise: objects are equal when they are the same object, arrays when they have the same items, and values VBA cannot compare (an array and a number, 'a' and 1) are not equal. Two numbers are still compared directly, so loops pay nothing for it.
    • for in a function literal — in a function written as a value (let f = fun() { for (let i = 1, ...) ... }), the initializer of a for was read as the comparison i == 1: the counter started empty and the loop did not run as written. Function literals are now normalised as named functions are.
    • Arrays to UNO methods (LibreOffice) — passing an ASF array to a UNO method or property (range.setDataArray(rows), table.setDataArray(rows)) failed: arrays now reach UNO as nested sequences from 0, converted to the type the member declares ([][]any even when every cell is a string).
    • Unknown members of arrays and strings — reading a member that arrays or strings do not have ([1].nope, 'abc'.nope.x) evaluated it as a call, and the call evaluated the member again, without end: VBA stopped with Out of stack space, LibreOffice crashed. Such a member is now undefined, and calling it ([1].nope()) is an error that names it: 'nope' is not a method of an array.
    • Operators that cannot take their operands — [1] + 1, {a: 1} * 2, 'abc' - 1 or [1] < 2 ended the script with VBA's Type mismatch (Object variable not set or Incorrect property value in LibreOffice). Every binary operator now raises an error that names the operator and its operands, such as Operator - cannot be applied to 'abc' and 1, which catch receives and LastError holds; << and >> also report arrays and objects instead of returning undefined. What VBA converts still works ('5' - 1 is 4), and division by zero and throw keep their own errors. + and & with a string write arrays and objects as templates do ('rows: ' + [1, 2] gives rows: [ 1, 2 ]), and null as nothing, also in LibreOffice, where 'a' + null was a type mismatch.
    • typeof without parentheses — typeof [1] did not compile (Invalid collapsed identifier), typeof 'a', typeof 3 or typeof -x were read wrongly, and typeof (o).a or typeof ('abc').length dropped what follows the parentheses. typeof takes any unary operand now, with or without parentheses, and typeof (x).y is the type of x.y, as in JavaScript.
    • Missing properties — reading a property an object does not have (o.nope) gave VBA's Nothing: typeof said null, o.nope == null was false, and a host that received it failed with Object variable not set. It is undefined now.
    • Templates — an object literal in a placeholder lost its closing brace (`${{a: 1}}` gave { a: 1 }}), a brace inside a string in a placeholder ended it (`${'}'}`), and an escaped backtick (\`) ended the template.
    • Brackets in strings and comments — the compiler counted the brackets of strings and comments when it checked that the program's brackets are balanced, so return 'a)'; or a comment with one parenthesis did not compile.
    • default in switch — the default block never ran: the tokenizer marks default as a keyword (for export default) and switch only looked for a name, so a value that matched no case did nothing. Writing a case as in JavaScript (case 2: return x;), which ASF does not have, ended the script with Invalid procedure call; it is now a compile error that shows the ASF form, case 2 { ... }.
    • Math constants and Math.random — Math.PI and Math.E gave undefined (the names were compared in upper case with the lower-cased member name, and a property read never reached them), and Math.random() did not exist although the Language reference uses it. Math has PI, E, LN2, LN10, LOG2E, LOG10E, SQRT2 and SQRT1_2 now, and random(); the Language reference has a section on Math.
    • join() and toString() — without a separator they joined the items with nothing (12) instead of the documented ', ' (1, 2).
    • VBA: ByRef argument type mismatch in ASF_VM — CallNamedFunction passed pinfo(1), an element of a Variant, to the stmts As Collection parameter of InvokeClosure, which VBA does not compile (LibreOffice Basic does not check it). The object parameters of InvokeClosure, CallNamedFunction and CallClosure are ByVal now, so a Variant that holds the object is accepted and converted when the call runs.
    • return [x] — a one-item array literal after return (and after typeof, throw, case, in, of, else, delete, void and instanceof) was read as an index on a variable named like the keyword, so return [3]; and return [3].length; returned nothing.
  • Test coverage: module_system_math_in_exported_function (with test/math_module.vas), template_literal_method_chain, equality_with_arrays_and_objects, return_array_literal, throw_reaches_catch, uncaught_throw_in_last_error, for_loop_in_function_literal, unknown_member_of_array_or_string, operators_on_arrays_and_objects, typeof_operand, missing_property_is_undefined, template_braces_quotes_backticks, join_default_separator, brackets_in_strings_and_comments, switch_default, switch_colon_case_is_an_error and math_constants_and_random in test/TestRunner.bas.