diff options
| -rw-r--r-- | TODO.md | 48 | ||||
| -rw-r--r-- | docs/LEARN.md | 6 | ||||
| -rw-r--r-- | examples/bf.zc | 2 | ||||
| -rw-r--r-- | src/compiler/compiler.zc | 76 | ||||
| -rw-r--r-- | src/lib/modules.txt | 5 | ||||
| -rw-r--r-- | src/lib/std.zc | 4 | ||||
| -rw-r--r-- | src/lsp/server.zc | 4 | ||||
| -rw-r--r-- | src/web/index.html | 5 | ||||
| -rw-r--r-- | tests/drivers/hint_fixes_test.js | 2 | ||||
| -rw-r--r-- | tests/icon/accept/step_globals.expected | 1 | ||||
| -rw-r--r-- | tests/icon/accept/step_globals.zc | 19 | ||||
| -rw-r--r-- | tests/icon/reject/begin_unknown_function.expected | 1 | ||||
| -rw-r--r-- | tests/icon/reject/begin_unknown_function.zc | 11 | ||||
| -rwxr-xr-x | tests/test.sh | 2 |
14 files changed, 148 insertions, 38 deletions
@@ -132,16 +132,40 @@ - [x] verify collector-growth accounting relative to existing allocations and investigate conservative roots retained after clearing large global arrays. - [x] allow repeated `_` discard placeholders in parameters and patterns, including tagged-enum payloads and catch-all cases; warn when a bound discard value is read. - [x] add generic native and hosted microcore thread contexts with isolated vm state, channels, cancellation and cleanup; verify 14 native and 12 microcore fixtures while keeping actor-specific code in its library. -- [ ] give core built-ins and every other toolchain module their own namespace and require an explicit include to access qualified exports: `include core;` enables `core.name`, with the same rule for all other modules. remove implicit toolchain imports, migrate maintained sources and generated code, and verify missing-include diagnostics, completions, hovers and navigation before expanding the standard library. -- [ ] add a generic include-time syntax-extension interface so imported libraries can extend compiler parsing and lowering without module-specific compiler code; keep all extension hooks generic and inactive unless the corresponding library is included. -- [ ] continue removing `unchecked` from the remaining runtime boundaries by teaching the analyzer the missing ownership and drop contracts; document any irreducible low-level escapes. The compiler, standard library and LSP no longer disable checking for their functions. -- [ ] continue fuzzing the compiler, analyzer, runtime, standard library, LSP, build tools and generated artifacts, including analyzer properties, memory-limit edges, compiler image mutation and long-running LSP memory use; fix discovered bugs and performance regressions. Current coverage includes malformed parser inputs, source immutability across runtime compilation, allocation/GC leak deltas, configured-memory growth, and available native, microcore, JavaScript and WebAssembly execution hosts. -- [ ] after the compiler namespace and fuzzing work, add more general functionality to the standard library. -- [ ] implement `include actor;` as a library that injects actor syntax into the compiler through the generic include-time extension interface: `actor` declarations in place of `struct`, implicit `this`, and generic `Actor<I,O>` input/output types. Provide asynchronous parallel execution with independent state and multiple instances; keep actor-specific code out of `compiler.zc` and every file it includes or reads by default, and cover syntax activation, execution, messaging and type safety with tests. -- [ ] document the public standard-library APIs with concise descriptions of behavior, parameters, ownership and return values where applicable; update reference and learning entries, add executable examples and record implemented changes in history; keep prose lowercase and verify docs appear in hovers. +- [x] give core built-ins and every other toolchain module their own namespace and require an explicit include to access qualified exports: `include core;` enables `core.name`, with the same rule for all other modules. remove implicit toolchain imports, migrate maintained sources and generated code, and verify missing-include diagnostics, completions, hovers and navigation before expanding the standard library. +- [x] add a generic include-time syntax-extension interface so imported libraries can extend compiler parsing and lowering without module-specific compiler code; keep all extension hooks generic and inactive unless the corresponding library is included. +- [x] implement `include actor;` as a library that injects actor syntax into the compiler through the generic include-time extension interface: `actor` declarations in place of `struct`, implicit `this`, and generic `Actor<I,O>` input/output types. Provide asynchronous parallel execution with independent state and multiple instances; keep actor-specific code out of `compiler.zc` and every file it includes or reads by default, and cover syntax activation, execution, messaging and type safety with tests. +- [x] implement and integrate `src/lib/icon.zc` with structured runtime syntax transformations, template matching, execution inspection and stepping, with explicit contracts and comprehensive tests. +- [x] change the producer of the genome header (`build/core/genome.h`) to emit a c translation unit that embeds the compiler, core and runtime zc sources with a `#embed` directive instead of concatenating them into a 1.5 mb generated header; keep the `.zc` sources as the single source of truth and extend the fixpoint check in `make genome` so it still verifies the emitted genome without materializing a header at all. +- [x] close the two ownership completeness limits that stop the compiler compiling itself, so `make genome` completes from a clean checkout: allow an owned value held in a local to move into another local when the destination's previous owner is released in the same statement list, and allow a global to hold a bounded borrow of a local so an output stream can be redirected at a scratch buffer without a module-level variable. also give `rt.code_blocks = m*block;` a supported spelling and fix the `only a named owned object can be recast` diagnostic, which does not describe the real constraint. written up in `docs/BOOTSTRAP-OWNERSHIP.md`, which also records a verified partial fix that removes five of the eight current errors. +- [x] bring documentation, examples, learn entries, history notes and test fixtures in line with the include and namespace format and the other language changes made alongside it: qualify runtime built-ins as `rt.put_s`, `rt.put_n`, `rt.put_c`, `rt.eof` and `rt.get_c`, require the explicit `include` each module needs, and remove the remaining bare builtin names so every shipped sample, every documented snippet and every expected-output fixture compiles and runs against the current compiler. the learn guide and `README.md` snippets are checked by the suite, so they are the gate, but the prose and the non-exercised samples are not. +- [x] add accept, reject and regression coverage for the actor and icon libraries once each is finished: for actors, syntax activation through the include-time extension, spawn/recv/send across input and output types, multiple instances of one actor, parallel execution, implicit `this`, and confirmation that no actor code is reachable from the compiler or anything it reads by default; for icon, find/replace over real syntax, undeclaring names, changing types, adding and rewriting blocks, evaluating parts of an expression, and stepping execution while reading locals and globals, including the failure cases for each. + +## open, easiest first + +every item still to do, including the ones added after the list above. sorted +by how hard each is to implement, so the large language features come last. +the final full suite stays at the very end whatever its size. + +- [ ] remove temporary markdown files: decide on `TASKLIST.md` (a record of an earlier session's requests), `docs/BOOTSTRAP-OWNERSHIP.md` (its problem is resolved) and `docs/design/handoff.md`, keeping anything still referenced from `README.md` or `ONBOARD.md`. +- [ ] verify every command in `ONBOARD.md` from a clean checkout and fix the ones that drifted. +- [ ] add `string` as a built-in alias of `char*`, in types, hovers and completions. +- [ ] untyped constants inside structs: `struct Text { const MAX = 24; }`, reached as `std.Text.MAX`, with the same rules as a local or top-level `const k = 5;`. +- [ ] typo suggestions for field and method names: `p.lenght` and `std.Text.itao` suggest the closest member, with the language server's change-to quick fix. +- [ ] a `make parity` runner that compiles the zc0-compatible programs (and the genome sources) with zc0 and with the self-hosted compiler, runs both images and compares output, so the two front ends can't disagree silently again (the `&&`/`||` precedence bug). +- [ ] c typedefs: `typedef T name;` declares a type alias, including pointer, array and function types, usable everywhere a type is, shown in hovers. +- [ ] continue removing `unchecked` from the remaining runtime boundaries by teaching the analyzer the missing ownership and drop contracts; document any irreducible low-level escapes. the compiler, standard library and lsp no longer disable checking for their functions. status: `copy_w`, `fill_w`, `cons`, `triple`, `dnew`, `dgrow` and `dpush` compile checked after small rewrites (uncommitted in `src/runtime/rt.zc`, bootstrap reaches its fixpoint, runtime tests not yet run). `free`, `recycle`, `recycle_leaf` and `gc` are the allocator and collector that the analyzer's own cleanup calls, so they stay unchecked and need to be documented as the irreducible escapes. `src/lib/actor.zc` has about 20 more. +- [ ] document the public standard-library apis with concise descriptions of behavior, parameters, ownership and return values where applicable; update reference and learning entries, add executable examples and record implemented changes in history; keep prose lowercase and verify docs appear in hovers. - [ ] revise diagnostics, comments and learning/reference prose using professional compiler documentation guidance, preserving lowercase and adding message regressions. -- [ ] implement and integrate `src/lib/icon.zc` with structured runtime syntax transformations, template matching, execution inspection and stepping, with explicit contracts and comprehensive tests. -- [ ] change the producer of the genome header (`build/core/genome.h`) to emit a c translation unit that embeds the compiler, core and runtime zc sources with a `#embed` directive instead of concatenating them into a 1.5 mb generated header; keep the `.zc` sources as the single source of truth and extend the fixpoint check in `make genome` so it still verifies the emitted genome without materializing a header at all. -- [ ] close the two ownership completeness limits that stop the compiler compiling itself, so `make genome` completes from a clean checkout: allow an owned value held in a local to move into another local when the destination's previous owner is released in the same statement list, and allow a global to hold a bounded borrow of a local so an output stream can be redirected at a scratch buffer without a module-level variable. also give `rt.code_blocks = m*block;` a supported spelling and fix the `only a named owned object can be recast` diagnostic, which does not describe the real constraint. written up in `docs/BOOTSTRAP-OWNERSHIP.md`, which also records a verified partial fix that removes five of the eight current errors. -- [ ] bring documentation, examples, learn entries, history notes and test fixtures in line with the include and namespace format and the other language changes made alongside it: qualify runtime built-ins as `rt.put_s`, `rt.put_n`, `rt.put_c`, `rt.eof` and `rt.get_c`, require the explicit `include` each module needs, and remove the remaining bare builtin names so every shipped sample, every documented snippet and every expected-output fixture compiles and runs against the current compiler. the learn guide and `README.md` snippets are checked by the suite, so they are the gate, but the prose and the non-exercised samples are not. -- [ ] add accept, reject and regression coverage for the actor and icon libraries once each is finished: for actors, syntax activation through the include-time extension, spawn/recv/send across input and output types, multiple instances of one actor, parallel execution, implicit `this`, and confirmation that no actor code is reachable from the compiler or anything it reads by default; for icon, find/replace over real syntax, undeclaring names, changing types, adding and rewriting blocks, evaluating parts of an expression, and stepping execution while reading locals and globals, including the failure cases for each. +- [ ] `defer` statement: `defer expr;` or `defer { ... }` runs when the enclosing block ends, on every exit path (fall-through, `return`, `break`, `continue`), in reverse order of declaration, with the values its expressions name at the time the block ends. follows the c defer proposal (n3199 style) with ownership awareness: a deferred call that consumes an owner counts as its transfer, so the analyzer neither frees it twice nor reports it leaked. +- [ ] test blocks: `test "name" { ... }` with `expect(cond)`, compiled only by `zy --test file.zc`, which runs each block and prints one line per test with the position of the first failed `expect`; skipped at parse time otherwise. built as a library through `run.syntax` and `run.statement_hook`, like actors. +- [ ] bounds checking on by default for indexing heap pointers (checked against the block header's payload size) and typed arrays (`T[n]`, `T[?]`), stopping with the index, the length and the source line. a keyword `unbounded`, used like `unchecked` (function, block, or top-level for the rest of the unit), turns it off. `o3` implies `unbounded`, so o3 code never pays for bounds checks. constant indexes into fixed arrays are checked at compile time and emit nothing. +- [ ] after the compiler namespace and fuzzing work, add more general functionality to the standard library. +- [ ] struct destructors: a struct may declare `fn drop()`, which the compiler calls wherever it frees an owned value of that type (scope end, reassignment, `rt.free`), before the memory is released. use it for file descriptors in `std.Host` and processes in `actor.zc`. decide and document what happens when an owner with a `drop` passes into unchecked code. +- [ ] runtime source positions: a line table per function (code offset to source position) stored in the image, behind a `lines on;` switch like `docs on;`. faults, failed bounds checks and a new `rt.trace()` print `file:line in function` for every frame on the interpreter, microcore and javascript vm; the jit and llvm backends map native addresses back to vm code. +- [ ] borrow returns tied to an argument, with syntax that stays out of the way: a function can return a pointer into one of its parameters (`find`, `skip_space`, `first`), the caller's analyzer treats the result as a borrow of whatever was passed, and freeing or moving that argument while the result is live is an error. the callee is checked to return only borrows of that parameter. prefer inference from the body over annotation; when a spelling is needed, keep it to the parameter's name. +- [ ] variadic arguments and `std.print`. variadics know their count, keep each argument's type, allow several packs per function when their element types differ (`void test(...int a, ...char b)`), and allow a mixed pack of any types (`...any args`). `...*any args` makes the call comma-free: `std.print("x = " name ", and they are " age " years old.\n");`. `std.print` is a global, javascript-like print that takes any number of arguments and formats each by its type (numbers, floats, strings, byte strings, pointers). +- [ ] continue fuzzing the compiler, analyzer, runtime, standard library, lsp, build tools and generated artifacts, including analyzer properties, memory-limit edges, compiler image mutation and long-running lsp memory use; fix discovered bugs and performance regressions. current coverage includes malformed parser inputs, source immutability across runtime compilation, allocation/gc leak deltas, configured-memory growth, and available native, microcore, javascript and webassembly execution hosts. +- [ ] keep improving the borrow checker: fewer annotations in ordinary code, clearer messages naming both the owner and the conflicting use, and new fixtures for each rule that changes. +- [ ] run the full suite once everything above is done, fix what it finds, and only then tick this item. + diff --git a/docs/LEARN.md b/docs/LEARN.md index b649b4f..a3588e7 100644 --- a/docs/LEARN.md +++ b/docs/LEARN.md @@ -8,15 +8,15 @@ build from the repository root, then run a source file on stdin: ```sh make -bin/zy < examples/learn/01-hello.zc +build/bin/zy < examples/learn/01-hello.zc ``` -`bin/zy` is the native core: it uses the arm64 jit where available and otherwise interprets. `bin/zym` is the portable microcore, `bin/zc0` is the bootstrap compiler, and `bin/zclsp` checks source for the editor. the interactive runners are `./tinyvm.sh` on linux and `tinyvm.bat` on windows. +`build/bin/zy` is the native core: it uses the arm64 jit where available and otherwise interprets. `build/bin/zym` is the portable microcore, `build/bin/zc0` is the bootstrap compiler, and `build/bin/zclsp` checks source for the editor. the interactive runners are `./tinyvm.sh` on linux and `tinyvm.bat` on windows. run from the root throughout this guide. paths in `rt.readfile` are resolved from the process's working directory, and so are those in `include` when nothing nearer has the file. `tests/drivers/learn.py` checks the examples and verifies that the code blocks here match their source files: ```sh -python3 tests/drivers/learn.py bin/zy +python3 tests/drivers/learn.py build/bin/zy ``` example 23 uses the native C ABI and requires host FFI support. the microcore does not provide that support, so skip example 23 when running the guide on a micro-only host; the learning driver does not currently select examples by backend capability. diff --git a/examples/bf.zc b/examples/bf.zc index 3971cbc..b3d3a41 100644 --- a/examples/bf.zc +++ b/examples/bf.zc @@ -28,7 +28,7 @@ fn translate(s) { case '[': emit("while (t[p]) {\n"); depth++; case ']': emit("}\n"); depth--; case '.': emit("rt.put_c(t[p]);\n"); - case ',': emit("t[p] = eof() ? 0 : get_c() & 255;\n"); + case ',': emit("t[p] = rt.eof() ? 0 : rt.get_c() & 255;\n"); } i++; } diff --git a/src/compiler/compiler.zc b/src/compiler/compiler.zc index 9c24af9..86e00c5 100644 --- a/src/compiler/compiler.zc +++ b/src/compiler/compiler.zc @@ -6742,7 +6742,7 @@ int brace_primary() { // variable the value is. int primary() { effect_value = 0; xprojection = 0; if_value = 0; - int n, i, s, c, k; word[8] bs0; int ft, mn, ms; + int n, i, s, c, k, npos, sv; word[8] bs0; int ft, mn, ms; lv = 0; lvk = LV_NONE; xzero = 0; xbor = -1; xconst = 0; xfloat = 0; xstr = 0; xlenloc = -1; xstamp = 0; xaf = 0; xvk = 0; if (tk == T_FLT) { op(OP_FLIT); emit(tv); xvk = 2; xvv = tv; xfloat = 1; xty = tfloat; next(); return C_PLAIN; } @@ -6839,6 +6839,7 @@ int primary() { xty = tword; return C_PLAIN; } + npos = tpack(); next(); xty = tword; if (s >= 0 && skind[s] == K_CONST) { @@ -6863,9 +6864,17 @@ int primary() { if (s >= 0 && skind[s] == K_GARR) { lit(sval[s]); if (stype[s]) xty = stype[s]; return C_PLAIN; } if (s >= 0 && skind[s] == K_ENH) return enhcall(s); if (s < 0 && is_op(s_dot)) { - // Text.itoa with no std: a library's static function, reported as one missing name peekat(0); - if (pk_tk == T_ID && export_owner(methname(n, pk_tv))) { next(); n = methname(n, tv); next(); } + if (pk_tk == T_ID && lib_file(n)) { + // lib.name before include lib, for a library read from a file: the lexer only joins names of loaded modules + sv = tpack(); tunpack(npos); + errat(); rt.put_s("module access requires `include "); rt.put_s(n); rt.put_s(";`"); errend(); + tunpack(sv); + word link = chk_resize(0, 0, 2); link[0] = missing_imports; link[1] = n; missing_imports = link; + next(); n = methname(n, tv); next(); + } + // Text.itoa with no std: a library's static function, reported as one missing name + else if (pk_tk == T_ID && export_owner(methname(n, pk_tv))) { next(); n = methname(n, tv); next(); } } if (s < 0) s = fwdfn_at(n, callpos); if (is_op(s_lt) && (sflag[s] & F_GEN)) { // f<int, char*>(...) @@ -9629,21 +9638,53 @@ word lib_scan(char* s) { while (list) { entry = list[0]; list[0] = back; back = list; list = entry; } return back; } -// the libraries under src/lib, scanned once: std and icon are embedded, actor is read like its include -word std_names, icon_names, actor_names; int names_read; +// the embedded libraries, scanned once +word std_names, icon_names; int names_read; word lib_names(char* module) { - char* save = incres; - if (!names_read) { - names_read = 1; - std_names = lib_scan(std_text()); icon_names = lib_scan(icon_text()); - char* text = inc_open("src/lib/actor.zc"); - if (text) actor_names = lib_scan(text); - rt.free(text); - incres = save; - } + if (!names_read) { names_read = 1; std_names = lib_scan(std_text()); icon_names = lib_scan(icon_text()); } if (rt.eq_w(module, "std")) return std_names; - if (rt.eq_w(module, "icon")) return icon_names; - return actor_names; + return icon_names; +} +// the libraries read from files, named in src/lib/modules.txt (one per line, # starts a +// comment), as a list of [next, name, declarations, scanned]. the compiler names none of them. +word file_libs; int file_libs_read; +word lib_files() { + int i = 0, a; word entry, tail = 0; char* save = incres; + if (file_libs_read) return file_libs; + file_libs_read = 1; + char* text = inc_open("src/lib/modules.txt"); + incres = save; + if (!text) return 0; + while (text[i]) { + while (text[i] == 32 || text[i] == 9 || text[i] == 10 || text[i] == 13) i++; + if (text[i] == '#') { while (text[i] && text[i] != 10) i++; continue; } + a = i; while (isidc(text[i])) i++; + if (i == a) { if (text[i]) i++; continue; } + entry = chk_resize(0, 0, 4); entry[1] = lib_copy(text, a, i); + if (tail) tail[0] = entry; else file_libs = entry; + tail = entry; + } + rt.free(text); + return file_libs; +} +// the entry of a file library, or 0 +word lib_file(char* name) { + word p = lib_files(); + while (p) { if (rt.eq_w(p[1], name)) return p; p = p[0]; } + return 0; +} +// a file library's declarations, read and scanned the first time they are needed +word lib_file_names(word entry) { + char* save = incres; + if (entry[3]) return entry[2]; + entry[3] = 1; + char* filename = inc_cat("src/lib", entry[1]); int length = rt.len_w(filename); + char* full = chk_resize(0, 0, length + 4); rt.copy_w(full, filename, length); rt.copy_w(full + length, ".zc", 4); + char* text = inc_open(full); + if (text) entry[2] = lib_scan(text); + rt.free(text); + incres = save; + return entry[2]; } // where name is in a library's list: Text.itoa is itself, a bare itoa is a top-level // declaration first, then a static method of some group. 0 when it is not there. @@ -9678,7 +9719,8 @@ word export_owners(char* name) { while (p) { export_add(p[1], export_in(p[1], name)); p = p[0]; } export_add("std", lib_path(lib_names("std"), name)); export_add("icon", lib_path(lib_names("icon"), name)); - export_add("actor", lib_path(lib_names("actor"), name)); + p = lib_files(); + while (p) { export_add(p[1], lib_path(lib_file_names(p), name)); p = p[0]; } return export_list; } char* export_owner(char* name) { diff --git a/src/lib/modules.txt b/src/lib/modules.txt new file mode 100644 index 0000000..7e157fd --- /dev/null +++ b/src/lib/modules.txt @@ -0,0 +1,5 @@ +# libraries under src/lib that are read from their file by `include name;`. +# std and icon are embedded in the compiler and are not listed. the compiler +# reads this list only to suggest a library for a name it can't find, so a +# library missing here still includes; it just isn't suggested. +actor diff --git a/src/lib/std.zc b/src/lib/std.zc index dfa9841..f0bc390 100644 --- a/src/lib/std.zc +++ b/src/lib/std.zc @@ -65,9 +65,9 @@ int libinit() { // returns it. writes go to the buffer instead of the terminal until end() // stops it, so the buffer is a string once end() has run: // let buf = capture.start(); -// put_s("hello world!"); // nothing on the terminal +// rt.put_s("hello world!"); // nothing on the terminal // capture.end(buf); -// put_s(buf); // hello world +// rt.put_s(buf); // hello world // one capture at a time, and the buffer belongs to whoever holds it. struct capture { diff --git a/src/lsp/server.zc b/src/lsp/server.zc index 2587c3b..1608c4c 100644 --- a/src/lsp/server.zc +++ b/src/lsp/server.zc @@ -3407,11 +3407,13 @@ int do_code_actions(int i) { start = ca_start; while (start > 0 && (hid(dc(base, start - 1)) || dc(base, start - 1) == '.')) start--; dot = start; while (dot < ca_end && dc(base, dot) != '.') dot++; + // the error can sit on the qualifier alone: actor in actor.vector + if (dot == ca_end && dot < dsize[i] && dc(base, dot) == '.' && run.lib_file(hname) && !run.module_imported(hname)) { ca_add(hname, 0, 0); send(gen_code_actions); return 0; } if (dot < ca_end) { // rt.put_c without include rt needs only the include; Text.itoa without std is std.Text.itoa char* owner = rt.new(dot - start + 1); k = start; n = 0; while (k < dot) { owner[n] = dc(base, k); n++; k++; } owner[n] = 0; - if (run.module_known(owner) || run.module_loaded(owner)) { if (!run.module_imported(owner)) ca_add(owner, 0, 0); } + if (run.module_known(owner) || run.module_loaded(owner) || run.lib_file(owner)) { if (!run.module_imported(owner)) ca_add(owner, 0, 0); } else { char* dotted = rt.new(ca_end - start + 1); k = start; n = 0; while (k < ca_end) { dotted[n] = dc(base, k); n++; k++; } dotted[n] = 0; diff --git a/src/web/index.html b/src/web/index.html index fbc203d..8480d43 100644 --- a/src/web/index.html +++ b/src/web/index.html @@ -27,8 +27,9 @@ <button id="run">run</button> <small id="status">loading</small> </div> - <textarea id="src" spellcheck="false">fn main() { - put_s("hello from the browser\n"); + <textarea id="src" spellcheck="false">include rt; +fn main() { + rt.put_s("hello from the browser\n"); return 0; } </textarea> diff --git a/tests/drivers/hint_fixes_test.js b/tests/drivers/hint_fixes_test.js index fffcbf5..20d3dd1 100644 --- a/tests/drivers/hint_fixes_test.js +++ b/tests/drivers/hint_fixes_test.js @@ -74,5 +74,7 @@ fixes('a misspelled export is corrected and imported', 'fn main() {\n\tputc(65); 'include rt;\nfn main() {\n\trt.put_c(65);\n\treturn 0;\n}\n', 'include rt and use rt.put_c'); fixes('a misspelled local function is corrected', 'int count_items() { return 1; }\nfn main() {\n\treturn count_item();\n}\n', 'count_item(', 0, 'int count_items() { return 1; }\nfn main() {\n\treturn count_items();\n}\n', 'change to `count_items`'); +fixes('a qualified name from a file library adds its include', 'include rt;\nfn main() {\n\treturn actor.vector();\n}\n', 'actor', 0, + 'include rt;\ninclude actor;\nfn main() {\n\treturn actor.vector();\n}\n', 'include actor'); console.log(ok + ' hint fix checks passed, ' + bad + ' failed'); process.exit(bad ? 1 : 0); diff --git a/tests/icon/accept/step_globals.expected b/tests/icon/accept/step_globals.expected new file mode 100644 index 0000000..8c5e263 --- /dev/null +++ b/tests/icon/accept/step_globals.expected @@ -0,0 +1 @@ +5 10 11 11 11 0 2 diff --git a/tests/icon/accept/step_globals.zc b/tests/icon/accept/step_globals.zc new file mode 100644 index 0000000..c584772 --- /dev/null +++ b/tests/icon/accept/step_globals.zc @@ -0,0 +1,19 @@ +include rt; +include run; +include icon; +int total = 1; +fn main() { + // step a fragment that writes an isolated global and a bound one, reading both after each step + let q = run.tokens("int n = 5; scale = scale * n; total = total + scale; return total;"); + let frame = icon.begin(q); + icon.set_global(frame, "scale", 2); + icon.bind_global(frame, "total"); + icon.step(frame); rt.put_n(icon.local(frame, "n")); rt.put_c(' '); + icon.step(frame); rt.put_n(icon.global(frame, "scale")); rt.put_c(' '); + icon.step(frame); rt.put_n(icon.global(frame, "total")); rt.put_c(' '); rt.put_n(total); rt.put_c(' '); + icon.step(frame); rt.put_n(icon.result(frame)); rt.put_c(' '); + // a name the frame never bound reads as 0 with error status 2 + rt.put_n(icon.global(frame, "missing")); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(10); + icon.close(d*frame); + return 0; +} diff --git a/tests/icon/reject/begin_unknown_function.expected b/tests/icon/reject/begin_unknown_function.expected new file mode 100644 index 0000000..1f338fc --- /dev/null +++ b/tests/icon/reject/begin_unknown_function.expected @@ -0,0 +1 @@ +1 4 0 diff --git a/tests/icon/reject/begin_unknown_function.zc b/tests/icon/reject/begin_unknown_function.zc new file mode 100644 index 0000000..6a8e5b3 --- /dev/null +++ b/tests/icon/reject/begin_unknown_function.zc @@ -0,0 +1,11 @@ +include rt; +include run; +include icon; +fn main() { + // an address that is no function has no tokens to step: no frame, error status 4 + let frame = icon.begin_function(12345); + rt.put_n(frame == 0); rt.put_c(' '); rt.put_n(icon.error()); rt.put_c(' '); + // stepping or reading a missing frame does nothing + rt.put_n(icon.step(0)); rt.put_c(10); + return 0; +} diff --git a/tests/test.sh b/tests/test.sh index 031d6d9..46625a6 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -223,6 +223,8 @@ s_interp() { python3 tests/drivers/array_methods_test.py $T/zy > $T/arrays.out 2>&1; r=$? grep -v '^ok' $T/arrays.out chk $r 0 "native array receiver, algorithm and ownership contracts" + # actors are a library: nothing the compiler compiles or reads by default mentions them + chk "$(grep -il actor src/compiler/compiler.zc src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default" python3 tests/drivers/actor_test.py $T/zy > $T/actor.out 2>&1; r=$? grep -v '^ok' $T/actor.out chk $r 0 "native isolated actor acceptance, rejection and regression fixtures" |
