v3.2.0 #48
minirang
announced in
Announcements
v3.2.0
#48
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Description
New: several libraries in one
usestatement.use DLC:math, DLC:string, DLC:convertloads all three; oneuseper line still works and gives the same result. Every item in the list needs its ownDLC:prefix (use DLC:math, stringis a syntax error). A dangling comma and a forgotten comma (use DLC:math DLC:string) each get a specific message instead of a confusingunexpected token ':'. An unknown library in the middle of a list (E5-004) is pointed at directly.SPEC.mdstill requires a module-load command to fit on one line, so a list cannot be continued onto the next line.UseStmtnow holds a list of{name, loc}for the DLC form.New: typed function parameters.
set func add_num(number n1, number n2) do:. Each parameter isnameortype name, withnumber,str,boolean,list,mapormatch. Typed and untyped parameters can be mixed. Passing a value of another type is a runtime error,ParameterTypeMismatch(E4-030), reported at the call site. Forasyncfunctions the check runs before the call is queued, so the error points at the call.emptyis accepted by every type, the same rule asset. A type keyword counts as a type only when a name follows it, so(number)and(number, x)remain valid untyped parameters. Functions with no typed parameter skip the check entirely.New: an interactive CuffScript shell,
cuffsh. Implementedcuffshto allow users to execute scripts in a REPL environment. Added command-line options for script execution, timeout settings, and network configurations. Created a fuzz testing script to identify potential crashes and runtime errors in the shell. Developed a harness for testing terminal interactions, including escape sequences and cursor movements. Implemented comprehensive test cases for multi-line editing, error handling, and input/output behavior, and added a shell script to run the test suite with dependencies.Changed: error codes print as
E<category>-<number>.E4005is nowE4-005,E2001isE2-001, and so on. The enum values in C++ are unchanged; only the printed tag is split, byerrorCodeTag(). The dash keeps a tag unambiguous if a category ever needs two digits (E10-001). Capacity within a category is still 999 numbers. 158 test/example files (.expected_codefiles andnote: E####headers) and all current docs were converted. Entries in this changelog from earlier releases keep the old format, as a record of what was printed then.Fixed: errors inside an f-string
{...}pointed at the wrong source line. The expression is tokenized separately, so its positions started over at line 1, column 1, and the source snippet added in the previous release then displayed line 1 of the file for any error inside an f-string. Locations for tokens in the fragment, and for any error thrown while tokenizing or parsing it, are now pinned to the f-string literal, so the snippet shows the line the f-string is on. The caret sits at the start of the literal, not at the exact column inside the braces. Two cases added totests/unit/error_snippet_test.cpp.Fixed:
tests/run.ps1did not work on Windows PowerShell 5.1. It usedProcessStartInfo.ArgumentList, which does not exist on .NET Framework, so every test failed with a null-method error. Rewritten, and these were fixed on the way: output is decoded as UTF-8 (the OEM code page garbled Korean output and failed every diff);\r\nis normalized before comparing; stdin is closed soinput()sees EOF instead of waiting for the timeout; g++ runs through the same helper rather than& g++ 2>, since under$ErrorActionPreference='Stop'PowerShell 5.1 turns any compiler warning on stderr into a terminating error, and the build timeout is 600 s instead of 10 s; unit tests link with-lws2_32and an 8 MiB stack on Windows, asMakefile.windoes; the binary iscuffc.exeon Windows and./cuffcelsewhere, so it also runs under PowerShell 7 on Linux/macOS. Not executed on a real Windows machine (none available here).Release binary is now stripped.
-sis added toMakefileandMakefile.win: 1.18 MB → 670 KB with no change in speed. It is skipped on macOS, where Apple's linker ignores the flag with a warning.Performance: measured, nothing else worth changing. Against the original engine:
fib(30), a 3M-iteration loop, 1M user-function calls, string/list/map work, f-strings and a 66k-line script are all at parity (differences inside run-to-run noise). The only profiler available wasgprof, and its profile was flat (evalExpr,evalBinaryOp, scope lookup). Tried and not adopted: profile-guided optimization (0–4%, inside noise, needs a two-step build),-O2instead of-O3(same), staticlibstdc++(startup 2.2 → 1.7 ms but a 2.4× larger binary), and dropping-fstack-protector/_FORTIFY_SOURCE(about 0–8%, not worth weakening a sandboxing interpreter). A micro-suite (200k-element sort,list_unique,splitinto 150k parts,replace/find/countover 850 KB, a 50k-object JSON round trip, a 50k-key map) found no quadratic behavior.Comments in
engine/cut from 1,534 lines to 92. Of 657 comment blocks, about 90 short ones remain: lifetime and ordering invariants, platform quirks (windef.hmacros, Emscripten's shadow stack,SIGPIPE,pthread_get_stackaddr_np), stack-safety limits, the reason behind non-obvious checks, and the publicCuffEngine::Optionsfields. Longer explanations are indocs/IMPLEMENTATION_NOTES.md. Checked mechanically: a string/char-literal-aware scanner found the comments; the preprocessed output ofmain.cppis identical before and after once whitespace is ignored; every string and char literal inengine/is byte-identical; build and suite pass unchanged.main.cpp,wasm/bindings.cppandtests/were not touched.Docs.
SPEC.md: typed parameters (§9), comma-separateduse(§13), new §14 on the error-code format and categories.README.md/README_ko.md: thepureparagraph still said the restriction covers only the function's own body, which was wrong since the call-graph hardening in the previous release, and is now corrected; typed parameters and theuselist are documented; the error example shows the caret and the new tag format; the directory tree now listsdlc/andnet/, which were missing.docs/IMPLEMENTATION_NOTES.md: new §35–39, plus the tag format in §20 and the f-string fix in §29.docs/EXTENDING.md: new §12–14 (parameter syntax,usesyntax, comment policy).SECURITY.md,tests/README.mdandexamples/README.mdupdated;examples/08_dlc_libraries.cuffshows bothuseforms.Tests: 8 new checks (
typed_parameters,use_multiple_dlcs, and the error casesparameter_type_mismatch,parameter_type_mismatch_async,use_multiple_unknown_dlc,use_multiple_missing_prefix,use_multiple_missing_comma,use_multiple_dangling_comma), and the f-string cases above. The suite is 124 checks, up from 116.Verification. Clean build, 124/124 passing. Also run clean: AddressSanitizer + UBSan over the whole suite, with a leak check on the new-feature scripts; libstdc++ debug mode (
_GLIBCXX_DEBUG);-pedantic -Wall -Wextra -Werror; each header underengine/dlc,engine/interpreter,engine/parserandengine/commoncompiled standalone. The one known LeakSanitizer finding (the intentionally circular lists invalue_semantics.cuff) is the same pre-existing one. Not done: nothing here was compiled or run on Windows or macOS, since no such toolchain exists in this environment. The new engine code is standard C++17 with no platform-specific API.run.ps1is reviewed by hand only.This discussion was created from the release v3.2.0.
All reactions