XSharpPublic icon indicating copy to clipboard operation
XSharpPublic copied to clipboard

Missing warning about not used value assigned to variable

Open cpyrgas opened this issue 1 year ago • 1 comments

First snippet causes a correct warning about unused value assigned to variable, but the next ones do not produce one. Shouldn't they?

FUNCTION Start() AS VOID
	LOCAL n,m,k AS INT
	n := 1
	n := 2 // warning XS0219: The variable 'n' is assigned but its value is never used
	
	m := 1
	m := m * 2 // no warning
	
	k := 1
	k++ // no warning

cpyrgas avatar Oct 12 '24 16:10 cpyrgas

In the examples with m and k, then the value of m is used in the 2nd expression and the value of k is also used in the second expression. So strictly speaking the original assignment to m and k is used on a subsequent statement.

RobertvanderHulst avatar Oct 13 '24 20:10 RobertvanderHulst

Roslyn does not support this.

RobertvanderHulst avatar Oct 16 '24 07:10 RobertvanderHulst