Skip to content

Fix compilation error pattern matching #1069

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/bindings/RescriptCompilerApi.res
Original file line number Diff line number Diff line change
Expand Up @@ -317,31 +317,31 @@ module CompileFail = {
let decode = (json): t => {
open JSON
switch json {
| String(type_) =>
| Object(dict{"type": String(type_)}) =>
switch type_ {
| "syntax_error" =>
let locMsgs = switch json {
| Object(dict{"erros": Array(errors)}) => errors->Array.map(LocMsg.decode)
| _ => throw(Failure(`Failed to decode erros from syntax_error. ${__LOC__}`))
| Object(dict{"errors": Array(errors)}) => errors->Array.map(LocMsg.decode)
| _ => throw(Failure(`Failed to decode errors from syntax_error. ${__LOC__}`))
}
// TODO: There seems to be a bug in the ReScript bundle that reports
// back multiple LocMsgs of the same value
locMsgs->LocMsg.dedupe->SyntaxErr
| "type_error" =>
let locMsgs = switch json {
| Object(dict{"erros": Array(errors)}) => errors->Array.map(LocMsg.decode)
| _ => throw(Failure(`Failed to decode erros from type_error. ${__LOC__}`))
| Object(dict{"errors": Array(errors)}) => errors->Array.map(LocMsg.decode)
| _ => throw(Failure(`Failed to decode errors from type_error. ${__LOC__}`))
}
TypecheckErr(locMsgs)
| "warning_error" =>
let warnings = switch json {
| Object(dict{"erros": Array(warnings)}) => warnings->Array.map(Warning.decode)
| Object(dict{"errors": Array(warnings)}) => warnings->Array.map(Warning.decode)
| _ => throw(Failure(`Failed to decode errors from warning_error. ${__LOC__}`))
}
WarningErr(warnings)
| "other_error" =>
let locMsgs = switch json {
| Object(dict{"erros": Array(errors)}) => errors->Array.map(LocMsg.decode)
| Object(dict{"errors": Array(errors)}) => errors->Array.map(LocMsg.decode)
| _ => throw(Failure(`Failed to decode errors from other_error. ${__LOC__}`))
}
OtherErr(locMsgs)
Expand Down