Title: [compiler] `IfExpression`s generating undefined instead of null · Issue #40 · lightscript/lightscript · GitHub
Open Graph Title: [compiler] `IfExpression`s generating undefined instead of null · Issue #40 · lightscript/lightscript
X Title: [compiler] `IfExpression`s generating undefined instead of null · Issue #40 · lightscript/lightscript
Description: Problem lightscript@0.5.9: x = if a: if b: c const x = a ? b ? c : void 0 : null; If a is false, x === null, but if a is true and b is false, x === undefined; this is inconsistent with the defined behavior of IfExpressions which is to pr...
Open Graph Description: Problem lightscript@0.5.9: x = if a: if b: c const x = a ? b ? c : void 0 : null; If a is false, x === null, but if a is true and b is false, x === undefined; this is inconsistent with the defined ...
X Description: Problem lightscript@0.5.9: x = if a: if b: c const x = a ? b ? c : void 0 : null; If a is false, x === null, but if a is true and b is false, x === undefined; this is inconsistent with the defined ...
Opengraph URL: https://github.com/lightscript/lightscript/issues/40
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[compiler] `IfExpression`s generating undefined instead of null","articleBody":"## Problem\r\n`lightscript@0.5.9`:\r\n```js\r\nx = if a:\r\n if b: c\r\n```\r\n```js\r\nconst x = a ? b ? c : void 0 : null;\r\n```\r\nIf `a` is false, `x === null`, but if `a` is true and `b` is false, `x === undefined`; this is inconsistent with the defined behavior of `IfExpression`s which is to produce `null` when the alternate is omitted.\r\n\r\n## Cause\r\nThis:\r\nhttps://github.com/lightscript/babel-plugin-lightscript/blob/eb650acf69a17f0e4af9ce10a4c1bdeacec1e9e7/src/index.js#L504\r\nwhich leads to this:\r\nhttps://github.com/babel/babel/blob/1e55653ac173c3a59f403a7b5269cf6d143d32d9/packages/babel-traverse/src/path/replacement.js#L195\r\nwhich leads to this:\r\nhttps://github.com/babel/babel/blob/master/packages/babel-types/src/converters.js#L47\r\n\r\nBabel's algorithm for converting statements to expressions produces `undefined` by default.\r\n\r\n## Resolution\r\nIt is probably necessary to recapitulate this algorithm inside the lsc transform and make sure it makes `null`s here.","author":{"url":"https://github.com/wcjohnson","@type":"Person","name":"wcjohnson"},"datePublished":"2017-06-26T17:13:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/40/lightscript/issues/40"}
| 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:706b2054-e21e-7d7d-1e7a-a097920d13b5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AAE6:129DF4:130B2B6:1BB8F8E:6A4E42E3 |
| html-safe-nonce | 956a80dd92614916dd60d7578870705bc857c04c3325731dbc4443ad59be40ba |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQUU2OjEyOURGNDoxMzBCMkI2OjFCQjhGOEU6NkE0RTQyRTMiLCJ2aXNpdG9yX2lkIjoiMjc2MzAzNTA3MTU3MzA0MDM1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a6c86f4d5ffd8efde69201a2983268ed0339b98b89081498871c2121ee8923d0 |
| hovercard-subject-tag | issue:238609957 |
| 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/lightscript/lightscript/40/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b239598a196384bd536cc49f58daa969e170180e889097ec1fc5af293312424c/lightscript/lightscript/issues/40 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b239598a196384bd536cc49f58daa969e170180e889097ec1fc5af293312424c/lightscript/lightscript/issues/40 |
| og:image:alt | Problem lightscript@0.5.9: x = if a: if b: c const x = a ? b ? c : void 0 : null; If a is false, x === null, but if a is true and b is false, x === undefined; this is inconsistent with the defined ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wcjohnson |
| hostname | github.com |
| expected-hostname | github.com |
| None | 030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/lightscript/lightscript git https://github.com/lightscript/lightscript.git |
| octolytics-dimension-user_id | 20427295 |
| octolytics-dimension-user_login | lightscript |
| octolytics-dimension-repository_id | 63191213 |
| octolytics-dimension-repository_nwo | lightscript/lightscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 63191213 |
| octolytics-dimension-repository_network_root_nwo | lightscript/lightscript |
| 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 | 9fabff9b8b127e686a3ec86f91422e818056ca2c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width