mirror of
https://github.com/Nexoniarz/Finch.git
synced 2026-11-03 08:54:25 +00:00
Warnings for big copies: a struct with 256+ bytes of plain data as a parameter or in for x in list
- on stderr (finch ir stays the IR), as yellow warnings in editors (@W in the index), once per place - str, arrays and maps inside a struct don't count: passing it copies only their handles - none in the compiler, the examples or the tests other than the new one - docs: the warning instead of "not planned"; what was and wasn't checked for Android Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GzNP6r8dg6WDxUVZy8wjL
This commit is contained in:
parent
961ba951ec
commit
d557b5505e
15 changed files with 210 additions and 18 deletions
|
|
@ -193,6 +193,15 @@ c.notify("textDocument/didChange", {"textDocument": {"uri": uri2, "version": 4},
|
|||
diags = c.diagnostics(uri2)
|
||||
check("error: unhandled failure", diags and "can fail" in diags[0]["message"], diags)
|
||||
|
||||
# a big struct copied on every call: a warning (yellow), not an error
|
||||
src4 = "struct V {\n" + "".join(" float f%d\n" % i for i in range(40)) + "}\n\nfn len2(V v) -> float {\n return v.f0\n}\n\nfn main() {\n print(len2(V()))\n}\n"
|
||||
path4 = os.path.join(d, "big.fch")
|
||||
open(path4, "w").write(src4)
|
||||
uri4 = pathlib.Path(path4).resolve().as_uri()
|
||||
c.notify("textDocument/didOpen", {"textDocument": {"uri": uri4, "languageId": "finch", "version": 1, "text": src4}})
|
||||
w4 = c.diagnostics(uri4)
|
||||
check("warning for a big copy", w4 and len(w4) == 1 and w4[0]["severity"] == 2 and "copied on every call" in w4[0]["message"] and w4[0]["range"]["start"]["line"] == 43, w4)
|
||||
|
||||
# a module imported under another name: completion after its name
|
||||
src3 = "import path as pt\n\nfn main() {\n print(pt.base(\"a/b\"))\n}\n"
|
||||
path3 = os.path.join(d, "alias.fch")
|
||||
|
|
|
|||
Loading…
Reference in a new issue