Bug in Winst 4.12.0.18 bei Funktionen

Antworten
toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von toddi »

Hallo,

ich habe seit der Version 4.12.0.0 die Funktionen intensiv genutzt. Dabei rufe ich eine Funktion mit Rückgabewert innerhalb einer if-Abfrage auf.
Seit der Version 4.12.0.18 erhalte ich jedoch eine Fehlermeldung.

Durch testen konnte ich das Problem wie folgt eingrenzen:
Wird eine Funktion innerhalb einer if-Abfrabe mit einer Varaiable als Parameter aufgerufen, kommt die folgende Fehlermeldung:
(TestFunction($FuncParam$) = "true") -> relation symbol ("<", "=", ">" ...) expected

Anhand des Test Scripts konnte ich den Fehler zuverlässig mit der Winst Version reproduzieren.

Code: Alles auswählen

[Initial]
setLogLevel=8
encoding=UTF-8

[Actions]
requiredWinstVersion >= "4.12.0.0"

DefVar $retVal$
DefVar $FuncParam$

; Variablen initialisieren.
Set $FuncParam$ = "true"

; Funktion definieren.
DefFunc TestFunction(val $param$ : string) : string
Set $result$ = $param$
endfunc

Message "Teste die Funktion..."

; Ok...
Set $retVal$ = TestFunction("true")
if ($retVal$ = "true")
	comment "Wahr."
else
	comment "Falsch."
endif

; Ok...
if (TestFunction("true") = "true")
	comment "Wahr."
else
	comment "Falsch."
endif

; Ok...
Set $retVal$ = TestFunction($FuncParam$)
if ($retVal$ = "true")
	comment "Wahr."
else
	comment "Falsch."
endif

; Fehler...
if (TestFunction($FuncParam$) = "true")
	comment "Wahr."
else
	comment "Falsch."
endif
Der Fehler Tritt auch mit der Version 4.12.0.19 auf.

Grüße, Torsten
Benutzeravatar
n.wenselowski
Ex-uib-Team
Beiträge: 3194
Registriert: 04 Apr 2013, 12:15

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von n.wenselowski »

Hallo Torsten,

danke für den Report mitsamt Testfall.
toddi hat geschrieben:Der Fehler Tritt auch mit der Version 4.12.0.19 auf.
In den letzten beiden Versionen gab es zahlreiche Verbesserung für die Verwendung von local functions. Ist das auch mit opsi-winst 4.12.0.21 noch ein Problem?


Gruß

Niko

Code: Alles auswählen

import OPSI
toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von toddi »

Hi,

gerade mit der 4.12.0.21 getestet. Der Fehler ist leider immer noch vorhanden.

Code: Alles auswählen

...
[6] [Jun 08 13:58:57:747] If
[8] [Jun 08 13:58:57:750]   We are coming from function with index: -1 (-1 = base)
[8] [Jun 08 13:58:57:751]   We enter the defined function: testfunction with 1 lines. inDefFuncLevel: 1
[8] [Jun 08 13:58:57:753]   Paramnr: 0 is : $FuncParam$) = "true"
[8] [Jun 08 13:58:57:755]   Paramnr: 0 is the string: true
[6] [Jun 08 13:58:57:756]   Set  $result$ = $param$
[6] [Jun 08 13:58:57:758]     The value of the variable "$result$" is now: "true"
[8] [Jun 08 13:58:57:759]   We leave the defined function: testfunction ; inDefFuncLevel: 0
[7] [Jun 08 13:58:57:761]   TestFunction($FuncParam$) = "true")    <<< syntax error, no result!! - set to false
[6] [Jun 08 13:58:57:763]   (TestFunction($FuncParam$) = "true")    <<< syntax error, no result!! - set to false
[2] [Jun 08 13:58:57:764]   Syntax Error in Section: Actions (Command in line 45 in section: Actions file: setup.opsiscript section start at line: 5; origin: setup.opsiscript line: 45): (TestFunction($FuncParam$) = "true") -> relation symbol ("<", "=", ">" ...) expected
[6] [Jun 08 13:58:57:767] Then
[2] [Jun 08 13:58:57:770]   Syntax Error in Section: Actions (Command in line 46 in section: Actions file: setup.opsiscript section start at line: 5; origin: setup.opsiscript line: 46): EndIf -> expected
[1] [Jun 08 13:58:57:775] ___________________
[1] [Jun 08 13:58:57:776] script finished: failed
[1] [Jun 08 13:58:57:778] 2 errors
[1] [Jun 08 13:58:57:780] 0 warnings
Grüße, Torsten
Benutzeravatar
n.wenselowski
Ex-uib-Team
Beiträge: 3194
Registriert: 04 Apr 2013, 12:15

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von n.wenselowski »

Hallo Torsten,

danke für deine Rückmeldung. Da das ganze noch immer auftritt, habe ich das als internes Ticket aufgenommen und wir werden uns das ganze anschauen.


Viele Grüße

Niko

Code: Alles auswählen

import OPSI
Benutzeravatar
d.oertel
uib-Team
Beiträge: 3327
Registriert: 04 Jun 2008, 14:27

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von d.oertel »

Hi,

bitte mal den probieren:
https://download.uib.de/opsi4.0/experim ... .22-1.opsi

Im Test läuft bei mir folgendes durch:

Code: Alles auswählen

[Initial]
setLogLevel=8
encoding=UTF-8

[Actions]
requiredWinstVersion >= "4.12.0.0" 

DefVar $retVal$
DefVar $FuncParam$
DefVar $Param1$
DefVar $Param2$

; Variablen initialisieren.
Set $FuncParam$ = "true" 
Set $Param1$ = "huh"
Set $Param2$ = "hah"

; Funktion definieren.
DefFunc TestFunction(val $param$ : string) : string
Set $result$ = $param$
endfunc

DefFunc TestFunction1($p1$ : string, val $param$ : string) : string
Set $result$ = $param$
endfunc

DefFunc TestFunction2($p1$ : string, val $param$ : string, $p2$ : string) : string
Set $result$ = $param$
endfunc


Message "Teste die Funktion..." 

Set $retVal$ = TestFunction("true")
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction("true") = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

Set $retVal$ = TestFunction($FuncParam$)
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction($FuncParam$) = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if ("true" = TestFunction($FuncParam$))
   comment "Wahr." 
else
   comment "Falsch." 
endif

if stringtobool(TestFunction($FuncParam$))
   comment "Wahr." 
else
   comment "Falsch." 
endif

;;################################################

Set $retVal$ = TestFunction1($Param1$,"true")
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction1($Param1$,"true") = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

Set $retVal$ = TestFunction1("huhu",$FuncParam$)
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction1($Param1$,$FuncParam$) = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if ("true" = TestFunction1($Param1$,$FuncParam$))
   comment "Wahr." 
else
   comment "Falsch." 
endif

if stringtobool(TestFunction1($Param1$,$FuncParam$))
	comment "Wahr." 
else
   comment "Falsch." 
endif

;;################################################

Set $retVal$ = TestFunction2($Param1$,"true",$Param1$)
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction2($Param1$,"true",$Param1$) = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

Set $retVal$ = TestFunction2("huhu",$FuncParam$,$Param1$)
if ($retVal$ = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if (TestFunction2($Param1$,$FuncParam$,$Param1$) = "true")
   comment "Wahr." 
else
   comment "Falsch." 
endif

if ("true" = TestFunction2($Param1$,$FuncParam$,$Param1$))
   comment "Wahr." 
else
   comment "Falsch." 
endif

if stringtobool(TestFunction2($Param1$,$FuncParam$,$Param1$))
   comment "Wahr." 
else
   comment "Falsch." 
endif
gruß

d.oertel


Vielen Dank für die Nutzung von opsi. Im Forum ist unser Support begrenzt.

Für den professionellen Einsatz und individuelle Beratung empfehlen wir einen Support-Vertrag und eine Schulung.
Gerne informieren wir Sie zu unserem Angebot.

uib GmbH
Telefon: +49 6131 27561 0
E-Mail: sales@uib.de


toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von toddi »

Hi,

ich habe gerade die Winst Version 4.12.0.22 erfolgreich getestet. Der Fehler ist dort behoben.
Besten dank!

Grüße, Torsten
toddi
Beiträge: 12
Registriert: 17 Mai 2018, 07:24

Re: Bug in Winst 4.12.0.18 bei Funktionen

Beitrag von toddi »

Hallo,

in der Winst Version 4.12.0.27 tritt der Fehler wieder auf.

Grüße, Torsten
Antworten