Project

General

Profile

Bug #462

Float Variables passed to procedure as a parameter aren't handled correctly.

Added by David Baldwin over 3 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
Start date:
09/01/2020
Due date:
% Done:

0%

Estimated time:
1:00 h
Affected version:

Description

Float Variables passed to procedure as a parameter aren't handled correctly.

// If A# is declared in procedure as 0.5, and not passed as a parameter, it works fine
#splashScreen:False
TEST[0.5]
Procedure TEST[A#]
Add A#,0.2
Print A#;" Should be 0.7"
Add A#,-0.2
Print A#;" Should be 0.5 (or at least 0.3 as last add was ignored!)"
End Proc

#1

Updated by Brian Flanagan over 3 years ago

Verified... and I at least have it narrowed down.

It has to do with using the parameter passed directly.

If we set a local variable to the parameter value vs. using the parameter directly, then it works. See below:

// Inline the code works fine:
A#=0.5
Fix 1
Print "A#=";A#
Add A#,0.2
Print "Add A#,0.2=";A#
Add A#,-0.2
Print "Add A#,-0.2=";A#
Print
Print "Now the procedure:"
TEST[0.5] ' using the parameter variable fails.
Print
Print "And the second procedure:"
TEST2[0.5] ' re-assigning a local variable works.

// In the procedure it fails miserably!
Procedure TEST[A#]
    Print "A# = ";A#
    Add A#,0.2 // 0.7
    Print "Add A#,0.2=";A#;" (should be 0.7)"
    Add A#,-0.2
    Print "Add A#,-0.2=";A#;" (should be 0.5)"
End Proc

// In this procedure it works.
Procedure TEST2[B#]
    A#=B#
    Print "A# = ";A#
    Add A#,0.2 // 0.7
    Print "Add A#,0.2=";A#;" (should be 0.7)"
    Add A#,-0.2
    Print "Add A#,-0.2=";A#;" (should be 0.5)"
End Proc
#2

Updated by David Baldwin over 3 years ago

Narrowed it down? That was exactly what I said.

#3

Updated by Brian Flanagan over 3 years ago

  • Estimated time set to 1:00 h
  • Affected version changed from 0.9.9.4-r3 to Beta RC2

Sorry, I guess you did say the same thing! ;-)

It was just the thought process I was in. I think I know what's happening now. It looks like the floating point type is not being set on the parameters, but it is on the local variables. I'm checking with Francois now find out where to make the change.

#4

Updated by Francois Lionet over 3 years ago

  • Status changed from New to Resolved

Fixed!

#5

Updated by David Baldwin over 3 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF