﻿id	summary	reporter	owner	description	type	status	milestone	component	version	severity	resolution	keywords	cc
3562	SetError fails if a function is called before returning	TheDcoder <TheDcoder@…>		"Hello! I have discovered another somewhat frustrating bug. SetError fails if a function is called before returning. Here is an example:
{{{
#include <MsgBoxConstants.au3>

Example()

If @error Then
	ConsoleWrite(""Error"" & @CRLF)
Else
	ConsoleWrite(""No Error"" & @CRLF)
EndIf

Func Example()
	SetError(1)
	Sleep(1000)
EndFunc
}}}

Expected output is `Error` but the actual output is `No Error` which should be wrong as we have called `SetError(1)`. If `Sleep(1000)` is removed then it works, this concludes that '''any error set using `SetError` will be erase if a function is called before returning'''!

Here is some more proof that the bug only occurs when using statements which call a function:
{{{
#include <MsgBoxConstants.au3>

Example()

If @error Then
	ConsoleWrite(""Error"" & @CRLF)
Else
	ConsoleWrite(""No Error"" & @CRLF)
EndIf

Func Example()
	SetError(1)
	Local $iNumber = @SEC
	If $iNumber * 1000 <= 1000 Then $iNumber = 0
EndFunc
}}}

This snippet will output `Error` as expected."	Bug	closed		AutoIt	3.3.14.2	None	No Bug	SetError	
