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

OpenComputers' overridden string.gsub fails on non-string inputs #1999

Closed
asiekierka opened this issue Aug 3, 2016 · 4 comments
Closed

OpenComputers' overridden string.gsub fails on non-string inputs #1999

asiekierka opened this issue Aug 3, 2016 · 4 comments
Assignees

Comments

@asiekierka
Copy link
Contributor

asiekierka commented Aug 3, 2016

Apparently, Lua 5.2 will automatically run tostring() on all "string" inputs for the gsub/etc. string functions overriden by OC, thus making OC's implementation incompatible when a non-string input is given. Other functions overridden by machine.lua must be checked in the same manner.

Also, why do you override lower and not upper?

@fnuecke
Copy link
Member

fnuecke commented Sep 18, 2016

Doesn't for me?

derp ~ # lua
Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> =string.gsub(false, "f", "")
stdin:1: bad argument #1 to 'gsub' (string expected, got boolean)
stack traceback:
        [C]: in function 'gsub'
        stdin:1: in main chunk
        [C]: in ?
> return string.gsub("false true", false, "")
stdin:1: bad argument #2 to 'gsub' (string expected, got boolean)
stack traceback:
        [C]: in function 'gsub'
        stdin:1: in main chunk
        [C]: in ?
>

Are you sure? Also not sure what you mean by not overriding upper?

@Vexatos
Copy link
Contributor

Vexatos commented Sep 18, 2016

Can confirm; the behaviour @fnuecke observed occurs on Lua 5.3.1 as well.

@asiekierka
Copy link
Contributor Author

Try numeric inputs.

Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio
> =string.gsub("f23", 2, 4)
f43 1
> 

@fnuecke
Copy link
Member

fnuecke commented Sep 19, 2016

Ah, so it's a numbers thing. Blergh.

@payonel payonel self-assigned this Jan 28, 2020
@payonel payonel closed this as completed in f73dd9e Jun 7, 2020
Dream-Master pushed a commit to GTNewHorizons/OpenComputers that referenced this issue Jul 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants