Forum
Better parameters mismatch function (solved) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Better parameters mismatch function (solved) (/showthread.php?tid=2582)



Better parameters mismatch function (solved) - baltasarq - 12-13-2024

I was compiling my program when the compiler claimed (correctly) that there was an error in my code:
Code:
util.bas:105: error: Function 'FormatStr' takes 3 parameters, not 1
This message was correct, but instead of signaling the file name and the line where the error was present, it was showing the line number and the file name of where the function was defined!
It also messes with the line number, which corresponds to where the error happened, not where the function was defined. In my case, the error happened at line number 105 of player.bas, calling function FormatStr() defined in line number 39 of util.bas.
I think it would be better to expose both pieces of information, maybe this way:
Code:
player.bas: 105: error: Function 'FormatStr' takes 3 parameters, not 1
util.bas:39: error: Function 'FormatStr' defined here.
Well, something like that.


RE: Better parameters mismatch function - boriel - 12-14-2024

Can you post a minimal example to reproduce this error?
Otherwise, contact me privately and send me the source code so I can reproduce the error and fix it.  Rolleyes


RE: Better parameters mismatch function - baltasarq - 12-14-2024

Sure, say you have two files:

params_error.bas
Code:
sub foo(a as ubyte, b as ubyte)
    print a, ", ", b
end sub

params_error2.bas
Code:
#include "params_error.bas"
foo(42)

You compile, and the output is:
Code:
params_error.bas:3: error: Function 'foo' takes 2 parameters, not 1

While I think it should be, or at least ir would be more infomative being:

Code:
params_error2.bas:2: error: Function 'foo' takes 2 parameters, not 1
params_error.bas:3: error: Function 'foo' defined here.



RE: Better parameters mismatch function - boriel - 12-19-2024

Please try this new version and let me know if it works correctly now :-)
http://www.boriel.com/files/zxb/zxbasic-v1.18.0-beta6.tar.gz
http://www.boriel.com/files/zxb/zxbasic-v1.18.0-beta6.zip
http://www.boriel.com/files/zxb/zxbasic-v1.18.0-beta6-win32.zip
http://www.boriel.com/files/zxb/zxbasic-v1.18.0-beta6-linux64.tar.gz
http://www.boriel.com/files/zxb/zxbasic-v1.18.0-beta6-macos.tar.gz


RE: Better parameters mismatch function - baltasarq - 12-20-2024

Working correctly, thanks!!