HuubGitHub / dwscript

Automatically exported from code.google.com/p/dwscript
1 stars 0 forks source link

Compiler does not recognize methods that never return #474

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
function foo: integer;
begin
   raise Exception.Create('foo');
end;

This function will never return, and DWS's reachability analyzer should know 
that.  But it still emits a hint:

Hint: Result is never used

Original issue reported on code.google.com by masonwhe...@gmail.com on 7 Jul 2014 at 12:47

GoogleCodeExporter commented 8 years ago
Yes, the hint is there because it's a function.

Note that the hint isn't about never assigning a result value but about Result 
not being used (in DWS all variables are always initialized, even Result).

Something that never returns should ideally be a procedure. Do you have a 
scenario in which this wouldn't be code smell?

Original comment by zar...@gmail.com on 7 Jul 2014 at 6:29

GoogleCodeExporter commented 8 years ago
If the method in question is a virtual method in a class where its 
functionality doesn't make sense.  (Look at some of the TStream descendants, 
for example.)

Original comment by masonwhe...@gmail.com on 7 Jul 2014 at 1:20