-
Notifications
You must be signed in to change notification settings - Fork 464
Add throw
#7346
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
Add throw
#7346
Conversation
runtime/Stdlib_Exn.res
Outdated
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.
Should we add @@deprecated
to this module?
It has the same content as https://github.com/rescript-lang/rescript/blob/master/runtime/Stdlib_Error.res
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.
it doesn't have exactly the same content though, Error
is missing the definition of a JS exception that today is catched with Exn.Error(obj)
, but I agree the current situation is not ideal, maybe we could merge the two?
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.
I will explore this in another PR
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.
thanks for doing this @aspeddro, I think that's a nice improvement. I'm just not sure if we should also deprecate raise
, having both without any explanation feels a bit weird to me. I'm also not sure about what we should do for Stdlib.Exn
module, but I'd advise to keep this work for another PR to avoid bikeshedding on this topic.
runtime/Pervasives_mini.res
Outdated
@@ -1,5 +1,6 @@ | |||
/* Exceptions */ | |||
external raise: exn => 'a = "%raise" |
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.
should we deprecate raise or keep both for now?
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.
I will remove
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.
Done
We can add to deprecated attribute?
|
runtime/Stdlib.res
Outdated
@@ -100,6 +100,7 @@ async function main() { | |||
external import: 'a => promise<'a> = "%import" | |||
|
|||
let panic = Error.panic | |||
let throw = Error.throw |
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.
This is not zero-cost (causes a $$throw
function to be emitted in Stdlib.js). I am afraid we need to repeat the external
definition here.
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.
Done
runtime/Stdlib.res
Outdated
} | ||
``` | ||
*/ | ||
external throw: Error.t => 'a = "%raise" |
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.
Should I add the external here or just leave it in the Stdlib_Error.res
module?
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.
Maybe clearer to add it in Pervasives on top of the deprecated raise
instead?
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.
Done
CHANGELOG updated |
@aspeddro did you see my comment?
|
Yes, I will adjust |
Should we also have a |
Good idea. |
runtime/Pervasives.res
Outdated
@@ -1,6 +1,6 @@ | |||
/** | |||
Since [others] depend on this file, its public mli files **should not | |||
export types** introduced here, otherwise it would cause | |||
export types** introduced here, otherwise it would cause |
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.
This whole comment is obsolete and should be removed as there is no others
folder anymore (leftover from the old stdlib build procedure).
Or actually, there should be a module-level doc comment (/***
) instead explaining what the Pervasives module is.
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.
Comment removed a36b71d
Co-authored-by: Christoph Knittel <[email protected]>
Co-authored-by: Christoph Knittel <[email protected]>
Co-authored-by: Christoph Knittel <[email protected]>
Co-authored-by: Christoph Knittel <[email protected]>
Co-authored-by: Christoph Knittel <[email protected]>
Co-authored-by: Christoph Knittel <[email protected]>
* Add `throw` Deprecate `raise` and rename references * remove raise from Pervasives_mini.res * convert to external and add deprecated attr * restore tests/gentype_tests/typescript-react-example/package-lock.json * update analysis output * update CHANGELOG.md * move `throw` to Pervasives.res * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <[email protected]> * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <[email protected]> * Update runtime/Pervasives.res Co-authored-by: Christoph Knittel <[email protected]> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <[email protected]> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <[email protected]> * Update runtime/Stdlib_Error.resi Co-authored-by: Christoph Knittel <[email protected]> * update Stdlib_Bool and Stdlib_Char * remove comment --------- Co-authored-by: Christoph Knittel <[email protected]>
Deprecate
raise
and rename references.Close #7113