diff --git a/CHANGELOG.md b/CHANGELOG.md index 3270acbcb..90f6fd2a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## 1.66.1 + +* Deprecate user-defined Sass functions named `round()`, `mod()`, `rem()`, + `sin()`, `cos()`, `tan()`, `asin()`, `acos()`, `atan()`, `atan2()`, `pow()`, + `sqrt()`, `hypot()`, `log()`, `exp()`, `abs()`, and `sign()`. Defining + functions with these names will be an error in Dart Sass 2.0.0. In a more + immediate release, they will also be parsed as CSS calculations in ambiguous + cases. + ## 1.66.0 * **Breaking change:** Drop support for the additional CSS calculations defined diff --git a/lib/src/deprecation.dart b/lib/src/deprecation.dart index 5ea363008..867f8a505 100644 --- a/lib/src/deprecation.dart +++ b/lib/src/deprecation.dart @@ -69,6 +69,11 @@ enum Deprecation { deprecatedIn: '1.62.3', description: 'Passing null as alpha in the ${isJS ? 'JS' : 'Dart'} API.'), + mathFunctionName('math-fn-name', + deprecatedIn: '1.66.1', + description: + 'Defining a function with the same name as a CSS calculation.'), + /// Deprecation for `@import` rules. import.future('import', description: '@import rules.'), diff --git a/lib/src/parse/stylesheet.dart b/lib/src/parse/stylesheet.dart index 9e9f7b2ed..cfd81fde6 100644 --- a/lib/src/parse/stylesheet.dart +++ b/lib/src/parse/stylesheet.dart @@ -870,6 +870,37 @@ abstract class StylesheetParser extends Parser { "not" || "clamp") { error("Invalid function name.", scanner.spanFrom(start)); + } else if (name + case "round" || + "mod" || + "rem" || + "sin" || + "cos" || + "tan" || + "asin" || + "acos" || + "atan" || + "atan2" || + "pow" || + "sqrt" || + "hypot" || + "log" || + "exp" || + "abs" || + "sign") { + var suggestion = switch (name) { + "sign" || "rem" || "mod" || "exp" => 'Please rename it.', + _ => 'Either rename it or use the math.$name() function.' + }; + + logger.warnForDeprecation( + Deprecation.mathFunctionName, + 'Naming a Sass function "$name" is deprecated because it conflicts ' + 'with the new\n' + 'CSS $name() syntax. $suggestion\n' + '\n' + 'More info: https:/sass-lang.com/d/math-fn-name', + span: scanner.spanFrom(start)); } whitespace(); diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index bf4003b9c..1ba7b431c 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 8.2.1 + +* No user-visible changes. + ## 8.2.0 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index dcf7ca03d..998025d6b 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ 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: 8.2.0 +version: 8.2.1 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - sass: 1.66.0 + sass: 1.66.1 dev_dependencies: dartdoc: ^5.0.0 diff --git a/pubspec.yaml b/pubspec.yaml index 6c34677db..9ceb0d9bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.66.0 +version: 1.66.1 description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass