From 8d5e3d9a67b6a0badc95e6ba504a880dab5c64fd Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 25 Jul 2019 08:14:17 +0100 Subject: [PATCH 1/5] Include argument names when reporting range errors Closes #771 --- CHANGELOG.md | 4 ++++ lib/src/value/number.dart | 3 ++- pubspec.yaml | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8cf63b6..3191a522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.22.9 + +* Include argument names when reporting range errors. + ## 1.22.8 ### JavaScript API diff --git a/lib/src/value/number.dart b/lib/src/value/number.dart index dfbcb246..0a5e99f9 100644 --- a/lib/src/value/number.dart +++ b/lib/src/value/number.dart @@ -209,7 +209,8 @@ class SassNumber extends Value implements ext.SassNumber { var result = fuzzyCheckRange(value, min, max); if (result != null) return result; throw _exception( - "Expected $this to be within $min$unitString and $max$unitString."); + "Expected $this to be within $min$unitString and $max$unitString.", + name); } bool hasUnit(String unit) => diff --git a/pubspec.yaml b/pubspec.yaml index 6636b6f7..c53ff476 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.22.8 +version: 1.22.9-dev description: A Sass implementation in Dart. author: Dart Team homepage: https://github.com/sass/dart-sass From 44b542fcefa4e21cc8ccd88abdfce801fa5bc084 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 25 Jul 2019 08:20:56 +0100 Subject: [PATCH 2/5] Include argument names when reporting selector parse errors --- CHANGELOG.md | 2 +- lib/src/value.dart | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3191a522..a93aa1c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.22.9 -* Include argument names when reporting range errors. +* Include argument names when reporting range errors and selector parse errors. ## 1.22.8 diff --git a/lib/src/value.dart b/lib/src/value.dart index 120f3eb5..8cc0e793 100644 --- a/lib/src/value.dart +++ b/lib/src/value.dart @@ -120,7 +120,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString()); + throw _exception(error.toString(), name); } } @@ -140,7 +140,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString()); + throw _exception(error.toString(), name); } } @@ -161,7 +161,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString()); + throw _exception(error.toString(), name); } } From 382af499e0f3ac54b152efff2dd44b7bb3bbdf4a Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 25 Jul 2019 08:28:40 +0100 Subject: [PATCH 3/5] Avoid double "Error:" headers when reporting selector parse errors Closes #774 --- CHANGELOG.md | 2 ++ lib/src/value.dart | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a93aa1c2..621e4881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ * Include argument names when reporting range errors and selector parse errors. +* Avoid double `Error:` headers when reporting selector parse errors. + ## 1.22.8 ### JavaScript API diff --git a/lib/src/value.dart b/lib/src/value.dart index 8cc0e793..82875ece 100644 --- a/lib/src/value.dart +++ b/lib/src/value.dart @@ -120,7 +120,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString(), name); + throw _exception(error.toString().replaceFirst("Error: ", ""), name); } } @@ -140,7 +140,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString(), name); + throw _exception(error.toString().replaceFirst("Error: ", ""), name); } } @@ -161,7 +161,7 @@ abstract class Value implements ext.Value { } on SassFormatException catch (error) { // TODO(nweiz): colorize this if we're running in an environment where // that works. - throw _exception(error.toString(), name); + throw _exception(error.toString().replaceFirst("Error: ", ""), name); } } From d408a5994e9ff6b6eef72600495f1bedaef4a809 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 25 Jul 2019 08:31:16 +0100 Subject: [PATCH 4/5] Add a missing trailing "." to an error message Closes #775 --- lib/src/visitor/serialize.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/visitor/serialize.dart b/lib/src/visitor/serialize.dart index 8451fc28..34ce654a 100644 --- a/lib/src/visitor/serialize.dart +++ b/lib/src/visitor/serialize.dart @@ -562,7 +562,7 @@ class _SerializeVisitor _buffer.writeCharCode($lbracket); } else if (value.asList.isEmpty) { if (!_inspect) { - throw SassScriptException("() isn't a valid CSS value"); + throw SassScriptException("() isn't a valid CSS value."); } _buffer.write("()"); return; From d840b84b596f58d2bb58dd8957c4540bd8d842fc Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 25 Jul 2019 08:35:26 +0100 Subject: [PATCH 5/5] Clarify the error for the wrong number of positional arguments Closes #776 --- CHANGELOG.md | 3 +++ lib/src/ast/sass/argument_declaration.dart | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 621e4881..9d411238 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ * Avoid double `Error:` headers when reporting selector parse errors. +* Clarify the error message when the wrong number of positional arguments are + passed along with a named argument. + ## 1.22.8 ### JavaScript API diff --git a/lib/src/ast/sass/argument_declaration.dart b/lib/src/ast/sass/argument_declaration.dart index 21ea6b68..bc8dd89c 100644 --- a/lib/src/ast/sass/argument_declaration.dart +++ b/lib/src/ast/sass/argument_declaration.dart @@ -81,6 +81,7 @@ class ArgumentDeclaration implements SassNode { if (positional > arguments.length) { throw SassScriptException("Only ${arguments.length} " + "${names.isEmpty ? '' : 'positional '}" "${pluralize('argument', arguments.length)} allowed, but " "${positional} ${pluralize('was', positional, plural: 'were')} " "passed.");