Euphoria
Ticket #907:
Why don't I get a warning for unused variable within a procedure?
-
Reported by
Shian_Lee
Nov 17, 2014
The following code gives me a warning:
with warning
object x
Warning { not_used }:
<0229>:: temp.ex - module variable 'x' is not used
But the following code don't give me any warning:
with warning
procedure temp()
object x
end procedure
It used to give me a (very useful) warning in Euphoria 3.1.1.; is it a bug?
...tested on LinuxMint-17 64-bit, MATE terminal.
Details
1. Comment by SDPringle
Dec 25, 2014
Confirmed also on Euphoria 4.1al with Linux/32bit.
An unused variable inside a routine should cause a warning.
2. Comment by SDPringle
Oct 06, 2015
Also fails to report a warning on Euphoria 4.0.6 development Linux/32-bit.
3. Comment by SDPringle
Jan 31, 2016
This warning doesn't work in the procedure unless -strict is set. The docs do not say this.
4. Comment by jimcbrown
Jan 31, 2016
Sounds like, this is not a bug in the codebase of OpenEuphoria, but merely a documentation issue.
So, if we correct the docs, this ticket is fixed, right?
5. Comment by SDPringle
Jan 31, 2016
This is a bad change from Euphoria 3.1. It has been 13 months and nobody said the docs are wrong and the behavior was right. The strict flag has another purpose. If I turn on the not_used warning, it should tell me when a variable is not used. The only time when you might want to have unused variables is in the arguments. Of course GUIs need them.
I can speculate the intention was to require the strict flag for the parameters only of a routine and not the variable. If a dev can't get the docs right, how can we expect that he got the code right?
6. Comment by jimcbrown
Feb 01, 2016
Ok, that's a good argument. Unless the original dev pops up and disagrees, I'm perfectly happy using your speculation as the basis of the fix - both for code and the docs.
7. Comment by SDPringle
Feb 01, 2016
t_warnings.e only tests whether the syntax for warnings is understood by the front end. We need a much more rigorous testing in t_warnings.e to verify the warning directives are having their intended effect.
8. Comment by SDPringle
Feb 01, 2016
See ticket:952
9. Comment by SDPringle
Feb 01, 2016
See: hg:euphoria/rev/869af8eba03f
changeset: 6413:869af8eba03f branch: 4.0 tag: tip user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Mon Feb 01 22:10:15 2016 -0300 files: docs/refman_2.txt source/symtab.e description:
10. Comment by jimcbrown
Feb 02, 2016
I tracked the source of the change to a commit by Derek back in 2009: http://scm.openeuphoria.org/hg/euphoria/annotate/d0eba8faa6ec/source/symtab.e#1072
11. Comment by SDPringle
May 04, 2018
See: hg:euphoria/rev/5b8912a4a2cf
changeset: 6468:5b8912a4a2cf branch: 4.0 user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri May 04 10:00:59 2018 -0300 files: docs/release/4.0.6.txt description:
- updated the release notes. ticket 831, ticket 907, ticket 803, ticket 853, ticket 928, ticket 938, ticket 752, ticket 915, ticket 948, ticket 921