The author: "I think I prefer length over len, because then I'll use len as the variable name". One arm in check.ml, one row in the table beside it, and every (len x) in lib, test, examples, vendor, spike, docs, web, emacs, plan.org and NEXT.md rewritten. Shadowing and builtin/ had already taken most of the sting out: a (defn len ...) was legal and won in its own file, and builtin/len reached past it. What was left is that len was still a builtin — the defn earned a warning, and a wrapper had to say builtin/ at every inner call. Now there is nothing under the short name: len is an ordinary identifier in every position, which is what (let [len (length xs)] ...) wants. length takes over as shadowing's worked example rather than the feature losing one. shadow-builtin.flan, builtin-qualified.flan, pkgs/shadowed and the builtin/ rows in test_flan move to it and go on testing shadowing. A call to a len nothing defines is answered where an unknown function is, after every table and after the shadowing guard, so a program with its own len never reaches it. The sentence is said rather than guessed at — len and length are three edits apart and the did-you-mean's net is one — and the call is written back out through spell_arg, as-slice's spelling lifted out of it and now shared, so what is printed compiles. sand.flan:33 still calls the old name and is the author's to change; until it does, test_acceptance and test_session abort there. Both were run green against a copy with that one line changed. FIX.org says so.
27 lines
1.3 KiB
Plaintext
27 lines
1.3 KiB
Plaintext
;;;; A slice built backwards, for the survey rather than for a person.
|
|
;;;;
|
|
;;;; test/programs/bounds.flan already covers this, and cannot cover it here:
|
|
;;;; it picks its case out of (at args 1) and survey.sh runs every program
|
|
;;;; with no arguments at all. So the one backend comparison that would catch
|
|
;;;; check_slice's lo <= hi being re-gated on --no-bounds-checks is a program
|
|
;;;; that reaches the reversed slice on its own.
|
|
;;;;
|
|
;;;; What it pins is that both backends die here in *every* build. lo <= hi is
|
|
;;;; not a bounds check — it is the claim that the length word of the %slice
|
|
;;;; this expression builds is a count, and hi - lo is -1 — so
|
|
;;;; --no-bounds-checks has nothing here to drop, and running this sweep with
|
|
;;;; SURVEY_FLAGS=--no-bounds-checks must report the same MATCH as without it.
|
|
;;;; A backend that quietly builds the slice exits 0 while the other exits 134
|
|
;;;; and the survey says DIFFER.
|
|
;;;;
|
|
;;;; The two ends come from (length args), which is 1 for a program run with no
|
|
;;;; arguments and is not a number either optimiser can see, so the branch
|
|
;;;; cannot be folded away and the checker has no literal to object to.
|
|
(defn main [args [string]] i32
|
|
(let [s (bytes-view "hello")
|
|
hi (i32 (length args))
|
|
lo (+ hi 1)]
|
|
(print (slice s lo hi))
|
|
(println ""))
|
|
0)
|