Skip to content

Commit

Permalink
Remove workaround for #8937 after it has been fixed (#10149)
Browse files Browse the repository at this point in the history
- Since #8937 was fixed by #10104 the workaround is no longer needed
  • Loading branch information
radeusgd authored Jun 5, 2024
1 parent 149a2c8 commit 698f4b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import project.Errors.File_Error.File_Error
import project.Network.HTTP.Header.Header
import project.Network.HTTP.HTTP_Status_Code.HTTP_Status_Code
import project.Network.HTTP.Response_Body.Response_Body
import project.Network.HTTP.Response_Body.Throw_Unsupported_Error
import project.Network.URI.URI
import project.Nothing.Nothing
import project.System.File.Existing_File_Behavior.Existing_File_Behavior
Expand Down Expand Up @@ -135,7 +134,7 @@ type Response
is returned.
@format decode_format_selector
decode : File_Format -> Any -> Any
decode self format=Auto_Detect ~if_unsupported=Throw_Unsupported_Error =
decode self format=Auto_Detect ~if_unsupported=(Error.throw (File_Error.Unsupported_Type (resolve_file_metadata_for_response self))) =
self.body.decode format if_unsupported

## ALIAS parse as text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ type Response_Body
but the format could not be determined.
@format decode_format_selector
decode : File_Format -> Any -> Any
decode self format=Auto_Detect ~if_unsupported=Throw_Unsupported_Error =
decode self format=Auto_Detect ~if_unsupported=(Error.throw (File_Error.Unsupported_Type self.metadata)) =
File_Format.handle_format_missing_arguments format <| case format of
Auto_Detect ->
detected_format = Auto_Detect.get_reading_format self.metadata
if detected_format.is_nothing then Throw_Unsupported_Error.handle_default_or_overridden_value if_unsupported self else
if detected_format.is_nothing then if_unsupported else
self.decode detected_format
_ ->
type_obj = Meta.type_of format
Expand Down Expand Up @@ -228,21 +228,3 @@ delete_file : Any -> Nothing
delete_file file =
Context.Output.with_enabled <| file.delete
Nothing

## PRIVATE
This is a workaround for bug: https://github.com/enso-org/enso/issues/8937
Originally we wanted `~if_unsupported=(Error.throw (File_Error.Unsupported_Type self.metadata))`,
however due to the bug `self` is inaccessible in _suspended defaults_.
So, instead, we return this constant and then we check if that constant was
kept and generate the proper error inside of the method body where `self`
_is_ already accessible; or we pass the user argument as-is if it was
overridden with something else.
type Throw_Unsupported_Error
## PRIVATE
throw ~metadata = Error.throw (File_Error.Unsupported_Type metadata)

## PRIVATE
handle_default_or_overridden_value if_unsupported self_reference =
case if_unsupported of
Throw_Unsupported_Error -> if_unsupported.throw self_reference.metadata
overridden_value -> overridden_value

0 comments on commit 698f4b5

Please sign in to comment.