google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.3k stars 209 forks source link

starlark: fix bug in int(string, base=int) #344

Closed alandonovan closed 3 years ago

alandonovan commented 3 years ago

Previously, when int was called with an explicit base, it would report an error if the digit string starts with a base prefix for a different base, such as int("0b101", 16). Now, it uses the base prefix only if it matches the requested base, so the example above would return 0x0b101, as would int("0x0b101", 16).

The int(string, int) case has been split out for clarity.

Update doc.

Fixes #337