Gu3st...
2013-12-11 14:26:53
rep+ to the one/those that can explain and post a solution to this peculiar bug!
Simba's progress report:
What's peculiar is that when we try to print the value of var1 which we set to 3000, it prints "-30" instead (which is var2's value).
Then, when we try to print the value of var2 it proceeds to print "1", which is param1's value and var1's new value instead of "2" which it should have (which is param2's value).
Basically, Lape executes the following instead of what I posted above:
@nielsie95; @Dgby714; @Wizzup?;
#YoHoJo4Potato
type
TTest = record
someProcedure : procedure(var var1, var2 : Integer;
const param1, param2 : Integer);
end;
procedure TTest.someProcedureTest(var var1, var2 : Integer;
const param1, param2 : Integer);
begin
writeLn(var1);
var1 := param1;
writeLn(var2);
var2 := param2; // This line should not throw access violation error, but does.
// This line will never get executed due to access violation error:
writeLn(var1, ' ', var2);
end;
var
Test : TTest;
int1, int2 : Integer;
begin
// Assign the pointer to point to Test.someProcedureTest
Test.someProcedure := @Test.someProcedureTest;
// Set int1 to 3000, int2 to -30
int1 := 3000;
int2 := -30;
// Call the procedure with int1, int2, 1 and 2 as params.
// Pay attention to the order of the params: int1 is before int2
Test.someProcedure(int1, int2, 1, 2);
// This line will never get executed due to access violation error:
writeLn(int1, ' ', int2);
end.Simba's progress report:
Compiled successfully in 219 ms.
-30
1
Exception in Script: Runtime error: "Access violation" at line 13, column 8
Note: line 13 is "var2 := param2" and is the line that throws the error as line 12 (writeLn(var2)) is executed.What's peculiar is that when we try to print the value of var1 which we set to 3000, it prints "-30" instead (which is var2's value).
Then, when we try to print the value of var2 it proceeds to print "1", which is param1's value and var1's new value instead of "2" which it should have (which is param2's value).
Basically, Lape executes the following instead of what I posted above:
var1 := var2;
writeLn(var1);
var2 := param1;
writeLn(var2);
throw_error_lol('Because fuck you, Zyt3x. You piece of shit.');@nielsie95; @Dgby714; @Wizzup?;
#YoHoJo4Potato