You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
procs.prg: on VFP 9.0.0.7423, Second() resolves to the SECONDS() abbreviation even though the program declares PROCEDURE Second #37
procs.prg defines PROCEDURE Second returning "second", and the golden expects ? Second() to print second. On my VFP 9 (09.00.0000.7423, started with -A) it prints a seconds-since-midnight value instead. SECOND is not itself a native function — but it is a four-plus-character abbreviation of SECONDS, and the product resolves the abbreviation even though the program declares a procedure with that exact name:
? Second() && prints 51611.465 on 7423 — SECONDS(), the abbreviation
DO Second && prints "proc ran" — DO prefers the procedure
PROCEDURESecond
? "proc ran"RETURN"second"
Measured output on 09.00.0000.7423, -A start:
51611.465
proc ran
The compiler models the opposite choice on purpose — compiler.rs suppresses the abbreviated lookup when the name is declared in the program:
let found = builtins::lookup(&name.upper).or_else(|| (!self.declared.contains(&name.upper)).then(|| builtins::lookup_abbreviated(&name.upper)).flatten());
That is the friendlier design, but it is not what the product does, and the golden pins the VM's behavior rather than Visual FoxPro's. Suggestions:
Re-measure procs.prg; on my build the checked-in text does not reproduce.
Match the product: resolve a unique 4+-character built-in abbreviation for name() calls even when the name is declared (DO name keeps preferring the procedure — worth measuring both forms while at it). One caution before coding it: not every built-in accepts a 4-character abbreviation — measured on 7423, ? GETW("a b c") raises error 1, File 'getw.prg' does not exist., instead of resolving to a GETWORD* function — so the rule wants measuring per name rather than assuming the whole registry abbreviates. (GETW is also a two-way ambiguous prefix, which may be exactly why.)
Rename the test procedure to something that is not a built-in prefix, so procs.prg still covers DO/PROCEDURE/RETURN without the shadowing trap.
A side-effect makes this easy to spot in a sweep: the program prints a clock value on the product, so its output changes every run (see #35).
Activity