Title: Improper handling of negative signs with exponents and modulo · Issue #170 · vpython/glowscript · GitHub
Open Graph Title: Improper handling of negative signs with exponents and modulo · Issue #170 · vpython/glowscript
X Title: Improper handling of negative signs with exponents and modulo · Issue #170 · vpython/glowscript
Description: It seems that for some reason -10**2 was incorrectly being parsed as (-10)**2 instead of -(10**2). To fix this the preprocesser replaces all negative signs that don't directly follow "e", "E", or "**" and don't directly precede "=" with ...
Open Graph Description: It seems that for some reason -10**2 was incorrectly being parsed as (-10)**2 instead of -(10**2). To fix this the preprocesser replaces all negative signs that don't directly follow "e", "E", or "...
X Description: It seems that for some reason -10**2 was incorrectly being parsed as (-10)**2 instead of -(10**2). To fix this the preprocesser replaces all negative signs that don't directly follow "e&qu...
Opengraph URL: https://github.com/vpython/glowscript/issues/170
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improper handling of negative signs with exponents and modulo","articleBody":"It seems that for some reason `-10**2` was incorrectly being parsed as `(-10)**2` instead of `-(10**2)`. To fix this the preprocesser replaces all negative signs that don't directly follow `\"e\"`, `\"E\"`, or `\"**\"` and don't directly precede `\"=\"` with `- 1 *`. However, this changes parsing behavior on operators with greater or equal precedence to multiplication. This only actually matters for exponentiation and modulo, since multiplication and division don't care where the negative goes. Since the preprocesser doesn't check for whitespace after the exponentiation operator, `10 ** -2` is getting turned into `10 ** - 1 * 2` and parsed as `(10 ** (-1)) * 2` instead of `10 ** (-2)`. Since the preprocesser doesn't check for modulo, `5 % -2` is getting turned into `5 % - 1 * 2` and parsed as `(5 % (-1)) * 2` (which is `0`) instead of `5 % (-2)` (which is `1` if you ask JavaScript and `-1` if you ask CPython).\r\n\r\nThis is the exact spot where this is happening: [https://github.com/vpython/glowscript/blob/master/lib/compiling/GScompiler.js#L376](url)","author":{"url":"https://github.com/jackson-smith-a","@type":"Person","name":"jackson-smith-a"},"datePublished":"2023-04-07T00:32:20.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/170/glowscript/issues/170"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:510c37f2-2027-e35c-a912-ef348c905fea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B2A0:8B50E:6569E6A:8301C84:6975BEA4 |
| html-safe-nonce | cd06f681f11ad4b6970d72dca67188cde5b126091a1a3eeb7ceea880c2465378 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMkEwOjhCNTBFOjY1NjlFNkE6ODMwMUM4NDo2OTc1QkVBNCIsInZpc2l0b3JfaWQiOiI5MDc1NDUyMTAwOTczNTIzNTYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 10e3dacf3ba1a8a90f1b438ceb410ebbca73fb3deb745b574a59774a59bd6f11 |
| hovercard-subject-tag | issue:1658200627 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/vpython/glowscript/170/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ffaa94900c342ff957600c0dc6891cf48769c181628c1e36f00e9aa93452eb68/vpython/glowscript/issues/170 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ffaa94900c342ff957600c0dc6891cf48769c181628c1e36f00e9aa93452eb68/vpython/glowscript/issues/170 |
| og:image:alt | It seems that for some reason -10**2 was incorrectly being parsed as (-10)**2 instead of -(10**2). To fix this the preprocesser replaces all negative signs that don't directly follow "e", "E", or "... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jackson-smith-a |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/vpython/glowscript git https://github.com/vpython/glowscript.git |
| octolytics-dimension-user_id | 1280757 |
| octolytics-dimension-user_login | vpython |
| octolytics-dimension-repository_id | 187905631 |
| octolytics-dimension-repository_nwo | vpython/glowscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 187905631 |
| octolytics-dimension-repository_network_root_nwo | vpython/glowscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width