Skip to content
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

[sass-embedded] Error for simplifying custom function returned Calculation should not be treated as protocol error #2040

Closed
ntkme opened this issue Jul 20, 2023 · 2 comments

Comments

@ntkme
Copy link
Contributor

ntkme commented Jul 20, 2023

https://github.com/sass/sass/blob/524790175f9f236c9578217d2137b18e524e4e53/spec/embedded_sass.proto#L897-L900

  // The compiler must simplify any calculations it receives from the host
  // before returning them from a function. If this simplification produces an
  // error, it should be treated as though the function call threw that error.
  // It should *not* be treated as a protocol error.

Currently the embedded compiler throws a protocol error which causes compiler shutdown when user constructs an incorrect Calculation.

According to previous discussions (sass/embedded-protocol#98 & sass/dart-sass-embedded#118), for any host side input that the host relies on the compiler side logic for validation, the validation error should be result in CompileFailure instead of ProtocolError.

@ntkme
Copy link
Contributor Author

ntkme commented Jul 20, 2023

Actually, what happens in the current implementation is that it sends a ProtocolError with id 4294967295 followed by a CompileFailure. For example:

<Sass::EmbeddedProtocol::OutboundMessage: error: <Sass::EmbeddedProtocol::ProtocolError: type: :PARAMS, id: 4294967295, message: "Value.Calculation.arguments must have exactly 3 arguments for clamp().">>

<Sass::EmbeddedProtocol::OutboundMessage: compile_response: <Sass::EmbeddedProtocol::OutboundMessage::CompileResponse: failure: <Sass::EmbeddedProtocol::OutboundMessage::CompileResponse::CompileFailure: message: "Value.Calculation.arguments must have exactly 3 arguments for clamp().", span: <Sass::EmbeddedProtocol::SourceSpan: text: "foo()", start: <Sass::EmbeddedProtocol::SourceSpan::SourceLocation: offset: 6, line: 0, column: 6>, end: <Sass::EmbeddedProtocol::SourceSpan::SourceLocation: offset: 11, line: 0, column: 11>, url: "", context: "a {b: foo()}">, stack_trace: "- 1:7  root stylesheet
", formatted: "Error: Value.Calculation.arguments must have exactly 3 arguments for clamp().
  ╷
1 │ a {b: foo()}
  │       ^^^^^
  ╵
  - 1:7  root stylesheet">, loaded_urls: []>>

@ntkme
Copy link
Contributor Author

ntkme commented Jul 20, 2023

I think the actual problem is #2041. Closing this.

@ntkme ntkme closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant