Skip to content

Commit

Permalink
Fix a crash when writing @extend without a selector (#2499)
Browse files Browse the repository at this point in the history
Closes #2497
  • Loading branch information
nex3 authored Jan 22, 2025
1 parent 870ba06 commit f4908e7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.83.5-dev

* Fix the error message for `@extend` without a selector and possibly other
parsing edge-cases in contexts that allow interpolation..

## 1.83.4

* No user-visible changes.
Expand Down
7 changes: 7 additions & 0 deletions lib/src/interpolation_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ final class InterpolationMap {
var target = error.span;
if (target == null) return error;

if (_interpolation.contents.isEmpty) {
return SourceSpanFormatException(
error.message, _interpolation.span, error.source);
}

var source = mapSpan(target);
var startIndex = _indexInContents(target.start);
var endIndex = _indexInContents(target.end);
Expand Down Expand Up @@ -83,6 +88,8 @@ final class InterpolationMap {
/// generated from interpolation, this will return the full [FileSpan] for
/// that interpolated expression.
Object /* FileLocation|FileSpan */ _mapLocation(SourceLocation target) {
if (_interpolation.contents.isEmpty) return _interpolation.span;

var index = _indexInContents(target);
if (_interpolation.contents[index] case Expression chunk) {
return chunk.span;
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.4.13-dev

* No user-visible changes.

## 0.4.12

* Fix more bugs in the automated release process.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sass-parser/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sass-parser",
"version": "0.4.12",
"version": "0.4.13-dev",
"description": "A PostCSS-compatible wrapper of the official Sass parser",
"repository": "sass/sass",
"author": "Google Inc.",
Expand Down
4 changes: 4 additions & 0 deletions pkg/sass_api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 15.0.5-dev

* No user-visible changes.

## 15.0.4

* No user-visible changes.
Expand Down
4 changes: 2 additions & 2 deletions pkg/sass_api/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: sass_api
# Note: Every time we add a new Sass AST node, we need to bump the *major*
# version because it's a breaking change for anyone who's implementing the
# visitor interface(s).
version: 15.0.4
version: 15.0.5-dev
description: Additional APIs for Dart Sass.
homepage: https://github.com/sass/dart-sass

environment:
sdk: ">=3.3.0 <4.0.0"

dependencies:
sass: 1.83.4
sass: 1.83.5

dev_dependencies:
dartdoc: ^8.0.14
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass
version: 1.83.4
version: 1.83.5-dev
description: A Sass implementation in Dart.
homepage: https://github.com/sass/dart-sass

Expand Down

0 comments on commit f4908e7

Please sign in to comment.