Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in script error message for type mismatch #7966

Closed
James103 opened this issue Jan 31, 2020 · 6 comments
Closed

Error in script error message for type mismatch #7966

James103 opened this issue Jan 31, 2020 · 6 comments

Comments

@James103
Copy link
Contributor

@James103 James103 commented Jan 31, 2020

Version of OpenTTD

Since d7a928a-windows-win32 (Windows 7 Ultimate)

Expected result

"Your script made an error: parameter N has an invalid type A, expected: E"

Actual result

"Your script made an error: parameter N has an invalid type (null), expected: A"
Where,

  • N is the parameter number with the type mismatch
  • A is the actual input type
  • E is the type that the function or operation expects.

Steps to reproduce

  • Run the following code in an AI or Game Script: ScriptController.Sleep([1,2,3])
    It will generate the above error with N = 1, A = "array", E = "integer".
  • Run the following code in an AI or Game Script: ScriptController.Sleep(2e9)
    It will generate the above error with N = 1, A = "float", E = "integer".
  • Note that running "array(2e9)" will not generate the above error, instead, it will execute as normal, crashing the game in the process.

Note

To anyone trying to reproduce this issue, please comment what result you got, as well as the version of OpenTTD, the OS, and whether it's 32-bit or 64-bit.

@glx22
Copy link
Contributor

@glx22 glx22 commented Jan 31, 2020

I tried both ScriptController.Sleep() steps and I get the expected result. No (null) in the message but the actual types('array' and 'float').

@LordAro
Copy link
Member

@LordAro LordAro commented Jan 31, 2020

He's not specified, but from memory @James103 always runs a Win32 build for whatever reason. Could it be specific to that somehow?

@James103
Copy link
Contributor Author

@James103 James103 commented Jan 31, 2020

@glx22 What build did you attempt reproduction on (include the OpenTTD version, the OS, and whether it's 32-bit or 64-bit)?

@glx22
Copy link
Contributor

@glx22 glx22 commented Jan 31, 2020

I tried with 64-bit debug build of current master. But I can retry with 32-bit.

Edit: Ok bug confirmed for 32-bit.

glx22 added a commit to glx22/OpenTTD that referenced this issue Feb 1, 2020
@James103
Copy link
Contributor Author

@James103 James103 commented Feb 1, 2020

The following line is the root cause of the issue:

Raise_Error("parameter %d has an invalid type '%s' ; expected: '%s'", nparam, IdType2Name((SQObjectType)type), _stringval(exptypes));

@glx22
Copy link
Contributor

@glx22 glx22 commented Feb 1, 2020

Yes, it's because nparam is a 64-bit value

@LordAro LordAro closed this in 196157b Feb 1, 2020
douiwby added a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.