S-Man42 / GCWizard

GC Wizard
Other
44 stars 10 forks source link

Bug in Web version (Android works fine) GCW Script Sum function #1680

Closed Linsty closed 1 month ago

Linsty commented 4 months ago

Hi

When I was writing a script in GCW script in the web version I received a CAST error at the position of Sum(T) error GCW Script Web version

When I transfered this script to my phone (Android) the code works correct: executed GCW Script Android version

It's the same script as presented on: https://blog.gcwizard.net/manual/en/mathmatics/sum-2/

I had the same issue with the script Almost perfect numbers (which is similar)

DIM T FOR I = 15 TO 99 LISTCLEAR(T) DIVISORS(T, I) S = SUM(T) - I D = I - 4 IF S = D THEN PRINT I, D, T ENDIF NEXT afbeelding

Feel free to contact if you have questions.

Kind regards,

Marcia

t-m-z commented 4 months ago

Current test-status

Chrome/Web: Error Edge/Web: Error App: NO ERROR Android Studio SK Chrome(Web): NO ERROR Android Studio SK Edge(Web): NO ERROR Android Studio SK Emulator: NO ERROR

S-Man42 commented 4 months ago

As already stated. For me it looks like an JavaScript issue of some kind. If only the web version is affected, from my point of view, nothing else makes sense. The original code basis is the same, the only difference is the compiled target code, which is JavaScript for web and different for the apps. Since JS already made some problems in the past it is clear that there might be some limitations.

So, I believe the original code must do something which is differently interpretable. Maybe an implicit cast instead an explicit one. Maybe JS handles something like that different from the app target languages. Maybe there is something interpreted as a list or a string where an integer was meant. This thought makes totally sense because JS is well known for strange and unexpected type casts.

So my advise: Check the internal code of the related malicious function (SUM?) and have a look whether there is something not properly and explicitely stated.

Another typical error would be something with integer exceeding bounds, which is always a problem in JS, whereas it is not in the other targets. But, to be honest, the basic code does not look like it does something with huge numbers...

t-m-z commented 4 months ago

That sounds reasonable.

However: If I compile to web and run the app locally with Chrome or Edge there is no error running the script. If I run the script on your server the error occurs. Why is there a difference between the local server and the remote server?

Sent from MailDroid

-----Original Message----- From: MLorenz42 @.> To: S-Man42/GCWizard @.> Cc: Thomas @.>, Assign @.> Sent: Di., 28 Mai 2024 0:09 Subject: Re: [S-Man42/GCWizard] Bug in Web version (Android works fine) GCW Script Sum function (Issue #1680)

As already stated. For me it looks like an JavaScript issue of some kind. If only the web version is affected, from my point of view, nothing else makes sense. The original code basis is the same, the only difference is the compiled target code, which is JavaScript for web and different for the apps. Since JS already made some problems in the past it is clear that there might be some limitations.

So, I believe the original code must do something which is differently interpretable. Maybe an implicit cast instead an explicit one. Maybe JS handles something like that different from the app target languages. Maybe there is something interpreted as a list or a string where an integer was meant. This thought makes totally sense because JS is well known for strange and unexpected type casts.

So my advise: Check the internal code of the related malicious function (SUM?) and have a look whether there is something not properly and explicitely stated.

Another typical error would be something with integer exceeding bounds, which is always a problem in JS, whereas it is not in the other targets. But, to be honest, the basic code does not look like it does something with huge numbers...

-- Reply to this email directly or view it on GitHub: https://github.com/S-Man42/GCWizard/issues/1680#issuecomment-2134093862 You are receiving this because you were assigned.

Message ID: @.***>

t-m-z commented 4 months ago

It's more than a casting bug: has also a problem printing the result of a mathmatical method/function.

image image

S-Man42 commented 4 months ago

Yes, it was just a quick guess. I am sure, it's something deeper, but without debuggin it will be hard.

S-Man42 commented 4 months ago

And here it could be something else. If t was filled with whatever, it may be, that the entire expression print(t) becomes something weird...

t-m-z commented 4 months ago

Yes. And that's the point where the problem starts: I cannot reproduce it within Android Studio

Sent from MailDroid

-----Original Message----- From: MLorenz42 @.> To: S-Man42/GCWizard @.> Cc: Thomas @.>, Assign @.> Sent: Di., 28 Mai 2024 20:38 Subject: Re: [S-Man42/GCWizard] Bug in Web version (Android works fine) GCW Script Sum function (Issue #1680)

Yes, it was just a quick guess. I am sure, it's something deeper, but without debuggin it will be hard.

-- Reply to this email directly or view it on GitHub: https://github.com/S-Man42/GCWizard/issues/1680#issuecomment-2135886531 You are receiving this because you were assigned.

Message ID: @.***>

t-m-z commented 4 months ago

Yes. And that's the point where the problem starts again: I cannot reproduce it within Android Studio.

Sent from MailDroid

-----Original Message----- From: MLorenz42 @.> To: S-Man42/GCWizard @.> Cc: Thomas @.>, Assign @.> Sent: Di., 28 Mai 2024 20:40 Subject: Re: [S-Man42/GCWizard] Bug in Web version (Android works fine) GCW Script Sum function (Issue #1680)

And here it could be something else. If t was filled with whatever, it may be, that the entire expression print(t) becomes something weird...

-- Reply to this email directly or view it on GitHub: https://github.com/S-Man42/GCWizard/issues/1680#issuecomment-2135889564 You are receiving this because you were assigned.

Message ID: @.***>

S-Man42 commented 4 months ago

Yes, I understand... Well that's tricky. The only way I see is: Put a bunch auf print statements into the dart code (or even better, into the GCW Script debug widget) , compile, put this version to test.gcwizard.net and check what is returned there... Check, fail, repeat... until not fail... Nasty and time-consuming thing! But I dont know any better if every local way works...

t-m-z commented 2 months ago

dim t for i = 1 to 10 listclear(t) divisors(t, i) s = sum(t) print i, t, s next