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

Fix Lua handling of decimal values with zero mantissa #2355

Merged
merged 7 commits into from May 6, 2020

Conversation

danpat
Copy link
Member

@danpat danpat commented May 5, 2020

Issue

Fixes #2032
Deprecates #2066
Unblocks #2352

Fixes a bug where decimal numbers with a zero-sized mantissa don't serialize to the same original string in Lua 5.1/5.2, leading to incorrect string offsets being calculated when looking for string suffixes.

Ultimately, the bug manifests in tags like maxheight: 2.0 being incorrectly transformed into maxheight: 0.611, instead of maxheight: 2.

The fix is to continue treating "numeric_prefix" as a string up until it needs to be converted to a number (e.g. for multiplication), but not before.

Tasklist

  • Add tests
  • Add #fixes with the issue number that this PR addresses
  • Generally use squash merge to rebase and clean comments before merging
  • Update the changelog

Requirements / Relations

Link any requirements here. Other pull requests this PR is based on?

danpat added 2 commits May 5, 2020 15:39
…ua 5.1/5.2 drop the .0 part when serializing (but not Lua 5.3 for some reason).
}
} // namespace

// TODO: sweet jesus add more tests of this class!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do have a test suite of lua tag transforms. we just do it through the parsing stage so that it makes a whole round trip (osm.pbf -> valhalla::osmdata . see test/graphparser.cc

Copy link
Contributor

@purew purew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@danpat danpat merged commit 7b59b11 into master May 6, 2020
@danpat danpat deleted the danpat_fix_lua_zero_mantissa branch May 6, 2020 15:06
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 this pull request may close these issues.

Lua5.2 tag parser issue
3 participants