Bug #348
openA user defined function cannot call another user-defined function. (Causes internal error or program freeze.)
0%
Description
Example:
/*
Leap Year: Brian Flanagan
Parameter: y 4-digit year
Returns: Leap Year (1=leap, 0=not) ' Yes, there's a reason for 0 or 1
*/
Function "LeapYear",y
ly=0
If y=4*Int(y/4) Then ly=1
If y=100*Int(y/100) Then ly=0
If y=400*Int(y/400) THen ly=1
End Function(ly)
/*
Parameters: y 4-digit year
m month (1-12)
d day of month (1-31)
Returns: Day of year.
*/
Function "DayOfYear", y, m, d
doy=Int(3055*(m+2)/100)-91
If m>2 Then doy=doy-2+LeapYear(y)
doy=doy+d
End Function(doy)
Print DayOfYear(2020,1,31),DayOfYear(2020,4,18)
Result in this instance is an Internal Error.
Updated by Brian Flanagan over 4 years ago
- Affected version changed from 0.9.8.1 to 0.9.9.3
Retested in 0.9.9.3. Problem still exists. Causes program freeze.
Updated by Francois Lionet about 4 years ago
- Status changed from New to Resolved
- Assignee set to Francois Lionet
- Target version set to 0.9.9.4-r2
Fixed!
Updated by Brian Flanagan about 4 years ago
- Status changed from Resolved to Feedback
Tested in Beta RC3. Still broken.
Non-dimensioned array in line 21. LeapYear function is not recognized inside DayOfYear.
Updated by Francois Lionet about 4 years ago
- Status changed from Feedback to Resolved
- Target version changed from 0.9.9.4-r2 to Beta RC4
Fixed in RC4.
Updated by Brian Flanagan about 4 years ago
- Status changed from Resolved to Feedback
- Estimated time set to 2:00 h
After the 9 Oct updates, it no longer gets an internal error, however there is still a problem.
It may or may not be a related issue.
Using the same example code above, printing out the function results individually works, however, making multiple calls to the function in a single print statement gives unpredictable results. Example:
/*
Leap Year: Brian Flanagan
Parameter: y 4-digit year
Returns: Leap Year (1=leap, 0=not) ' Yes, there's a reason for 0 or 1
*/
Function "LeapYear",y
ly=0
If y=4*Int(y/4) Then ly=1
If y=100*Int(y/100) Then ly=0
If y=400*Int(y/400) THen ly=1
End Function(ly)
/*
Parameters: y 4-digit year
m month (1-12)
d day of month (1-31)
Returns: Day of year.
*/
Function "DayOfYear", y, m, d
doy=Int(3055*(m+2)/100)-91
If m>2 Then doy=doy-2+LeapYear(y)
doy=doy+d
End Function(doy)
// NOTE: All of the function calls work *individually*
Print DayOfYear(2020,1,31) ' Works (31)
Print DayOfYear(2020,2,29) ' Works (60)
Print DayOfYear(2020,3,3) ' Works (63)
Print DayOfYear(2020,4,18) ' Works (109)
Print DayOfYear(2020,12,31) ' Works (366)
// ...but not when multiple items are printed on the same line.
Print DayOfYear(2020,1,31),DayOfYear(2020,1,31) ' Both work.
Print DayOfYear(2020,1,31),DayOfYear(2020,4,18) ' Works 2nd x only. (wrong result on 1st)
Print DayOfYear(2020,1,31),DayOfYear(2020,12,31) ' Works 2nd x only. (wrong result on 1st)
Print DayOfYear(2020,1,31),DayOfYear(2020,12,31),DayOfYear(4,18) ' Works 2nd x only (wrong result on 1st, 3rd x = NaN)
Print DayOfYear(2020,1,31),DayOfYear(2020,2,29),DayOfYear(2020,4,18),DayOfYear(2020,12,31) ' Wrong result on 1st
Print DayOfYear(2020,1,31),DayOfYear(2020,2,29),DayOfYear(2020,4,18),DayOfYear(2020,12,31),DayOfYear(2020,3,3) ' Wrong result on 1st
Updated by Brian Flanagan almost 4 years ago
- Affected version changed from 0.9.9.3 to 1.0.0 (B3)
This was partially fixed before, however, it is now completely broken again.
Newest test was in 1.0.0 B3 (2/12/2021).
Example:
Function "Number1$"
End Function("one")
Function "Number2$"
End Function(Number1$+" two")
Print "Number1: ";Number1$ // This works (by itself - you'll have to comment the last line)
Print "Number2: ";Number2$ // Should print "one two", but fails.
Updated by Brian Flanagan almost 4 years ago
- Target version changed from Beta RC4 to 1.0.0 (B3)
Updated by Brian Flanagan almost 4 years ago
- Priority changed from Normal to High