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

tonumber doesn't handle E notation correctly #472

Open
2 tasks done
hugebubu opened this issue Jan 3, 2024 · 1 comment · May be fixed by #473
Open
2 tasks done

tonumber doesn't handle E notation correctly #472

hugebubu opened this issue Jan 3, 2024 · 1 comment · May be fixed by #473

Comments

@hugebubu
Copy link

hugebubu commented Jan 3, 2024

You must post issues only here. Questions, ideas must be posted in discussions.

  • GopherLua is a Lua5.1 implementation. You should be familiar with Lua programming language. Have you read Lua 5.1 reference manual carefully?
  • GopherLua is a Lua5.1 implementation. In Lua, to keep it simple, it is more important to remove functionalities rather than to add functionalities unlike other languages . If you are going to introduce some new cool functionalities into the GopherLua code base and the functionalities can be implemented by existing APIs, It should be implemented as a library.

Please answer the following before submitting your issue:

  1. What version of GopherLua are you using? : v1.1.0
  2. What version of Go are you using? : 1.20
  3. What operating system and processor architecture are you using? : MacOS/ARM
  4. What did you do? : print(tonumber("2e2"))
  5. What did you expect to see? : 200
  6. What did you see instead? : nil
@hugebubu
Copy link
Author

hugebubu commented Jan 3, 2024

Hi there, I met a case where Lua 5.1 can successfully convert "2e2" into number where gopher-lua returns nil. This is what I tried in the REPL:

$ lua5.1
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> print(tonumber("2e2"))
200

I am trying to patch baselib.go#L404 so that gopher-lua works for me in such cases, hopefully my patch could merged back to the upstream too.

Is there any specification for tonumber that I am unaware of? I will try to make it compliance to spec if there is one.
I am looking at https://www.lua.org/source/5.1/lvm.c.html#luaV_tonumber in the meanwhile.

hugebubu pushed a commit to hugebubu/gopher-lua that referenced this issue Jan 3, 2024
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

Successfully merging a pull request may close this issue.

1 participant