I agree that better error checks are good, but the design goal of the #pike construct is to be able to keep running code that is de facto running on older pike versions.
Granted, the old code is not bug free, and it will probably misbehave in some corner cases. But the fact remains that the code is working good enough in practice, and so it shouldn't loudly stop working when a new pike is used in compat mode.
All the test cases I've committed so far are condensed from code like that. For example, here's a real case:
mapping find_file(string file, object id) { string cache_id; string result; int menunum; string menutype; string imagetype; if(sscanf(file,"%s/%s/%s/_.%s", cache_id,menunum,menutype,imagetype)<4) return 0;
object f=Stdio.File();
if(!f->open(get_cache_dir()+"/"+cache_id+"/"+menutype+menunum+"."+imagetype,"r")) { return 0; } return http_file_answer(f,"image/"+imagetype); }
menunum has the wrong type here. During runtime a string will be stored there. That usually works just fine in this function. The only problem might be that it doesn't fail correctly in case the input string is incorrectly formatted and doesn't contain a formatted integer after the first "/" (that's assuming that the type is correct and the sscanf format is wrong; it could be the other way around too).
This code is flawed, but it has been working good enough. In compat mode it should continue to do so. The errors may still be reported as warnings, though.
I partly agree. -V was made for hassle-less running of stuff you don't have time to get up to date right now. And I suspect the sprintf stuff might be major there.
On the other hand we've OK:ed bugfixes without requiring backwards compatibility before, where it was a clear bugfix. But when it was a bug fix in Pike, not a detecting bugs in the program pike is trying to run. So I'm not sure I think it's a blocker, but I'm concerned.
The question to grubba is: Can backwards compatibility be fixed without spending weeks on it and without losing something (like performance) in the process? A warning instead of an error would be might nice for code like this, but the primary concern is running the code, not running it better than it used to run on the Pike the compatibility layer is emulating.
I agree. Either there's a compat mode that works on all conceivable levels, or the compat mode isn't a compat mode (and then it doesn't have a point).
Does anything in the compiler actually stop it from creating useful code? Or is the error just from non-code-creating typechecking?
pike-devel@lists.lysator.liu.se