Skip to content

Strange arguments behaviour on methods with default parameters #629

@LeonidLevenshtein

Description

@LeonidLevenshtein
CLASS MadnessClass

	METHOD TestMadness(a1 AS INT, a2 AS STRING, a3 := NULL_DATE AS DATE, a4 := FALSE AS LOGIC, a5 := NIL AS USUAL) AS USUAL STRICT

		? a1	// prints random number instead of 5
		? a2	// prints empty string instead of "test1"
		? a3	// empty date - ok
		? a4	// .F. - ok
		? a5	// test2 - ok

	RETURN a5

	METHOD RunTest() AS VOID STRICT

		? SELF:TestMadness(5, "test1",,, "test2")

	RETURN

END CLASS


FUNCTION Start() AS VOID STRICT

	MadnessClass{}:RunTest()

	WAIT

RETURN

The arguments seem to be dislocated. Instead of 5 it prints some random number, it looks like the address of string in the second argument.

PS. The problem exists when there is at least one empty comma in the call. It could be:

SELF:TestMadness( 5, "test1", )

and the problem would remain. But if there are no empty commas, then it works fine.

PPS. Found out that changing default value of DATE argument to NULL instead of NULL_DATE solves the problem. But I still think that's an issue.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions