-
Notifications
You must be signed in to change notification settings - Fork 464
Support bool untagged variants #6368
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "unboxed_bool_with_const", | ||
"version": "0.1.0", | ||
"sources": [ | ||
{ | ||
"dir": "src", | ||
"subdirs": true | ||
} | ||
], | ||
"package-specs": { | ||
"module": "commonjs", | ||
"in-source": true | ||
}, | ||
"suffix": ".bs.js" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
//@ts-check | ||
|
||
var cp = require("child_process"); | ||
var assert = require("assert"); | ||
var rescript_exe = require("../../../scripts/bin_path").rescript_exe; | ||
|
||
var out = cp.spawnSync(rescript_exe, { | ||
cwd: __dirname, | ||
encoding: "utf8", | ||
}); | ||
|
||
assert.equal( | ||
out.stdout.slice(out.stdout.indexOf("Main.res:3:3-14")), | ||
`Main.res:3:3-14 | ||
|
||
1 │ @unboxed | ||
2 │ type t<'a> = | ||
3 │ | Bool(bool) | ||
4 │ | @as(false) False | ||
5 │ | @as(true) True | ||
|
||
This untagged variant definition is invalid: At most one case can be a boolean type. | ||
|
||
FAILED: cannot make progress due to previous errors. | ||
` | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@unboxed | ||
type t<'a> = | ||
| Bool(bool) | ||
| @as(false) False | ||
| @as(true) True |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,3 +272,17 @@ module CustomTagNotInline = { | |
let a = A(10) | ||
let b = B(20) | ||
} | ||
|
||
module UntaggedWithBool = { | ||
@unboxed @genType | ||
type t = String(string) | Float(float) | Bool(bool) | Object({name: string}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unrelate: this defines There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where does it define string twice? The object prop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it doesn't look right with this output. export type UntaggedWithBool_t = string | number | boolean | string; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahh, the two comments are connected! Now I see. |
||
|
||
let classify = x => | ||
switch x { | ||
| String(_) => "string" | ||
| Float(_) => "int" | ||
| Bool(true) => "true" | ||
| Bool(_) => "boolean" | ||
| Object({name}) => "Object" ++ name | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated: this does not look right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this unrelated to this specific PR?