Skip to content

Commit

Permalink
Fix null pointer errors in references (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
jathak authored Mar 12, 2024
1 parent 67f65a6 commit dce67db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.3

### Module Migrator

* Fixes some crashes due to null pointer errors.

## 2.0.2

### Calc Functions Interpolation Migrator
Expand Down
13 changes: 9 additions & 4 deletions lib/src/migrators/module/references.dart
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,9 @@ class _ReferenceVisitor extends ScopedAstVisitor {
var declaration = _scopeForNamespace(namespace).findVariable(node.name);
if (declaration != null && !_fromForwardRuleInCurrent(declaration)) {
_variables[node] = declaration;
var source = _declarationSources[declaration];
if (source != null) _sources[node] = source;
if (_declarationSources[declaration] case var source?) {
_sources[node] = source;
}
} else if (namespace == null) {
_unresolvedReferences[node] = currentScope;
}
Expand Down Expand Up @@ -645,7 +646,9 @@ class _ReferenceVisitor extends ScopedAstVisitor {
var declaration = _scopeForNamespace(namespace).findMixin(node.name);
if (declaration != null && !_fromForwardRuleInCurrent(declaration)) {
_mixins[node] = declaration;
_sources[node] = _declarationSources[declaration]!;
if (_declarationSources[declaration] case var source?) {
_sources[node] = source;
}
} else if (namespace == null) {
_unresolvedReferences[node] = currentScope;
}
Expand Down Expand Up @@ -673,7 +676,9 @@ class _ReferenceVisitor extends ScopedAstVisitor {
var declaration = _scopeForNamespace(namespace).findFunction(node.name);
if (declaration != null && !_fromForwardRuleInCurrent(declaration)) {
_functions[node] = declaration;
_sources[node] = _declarationSources[declaration]!;
if (_declarationSources[declaration] case var source?) {
_sources[node] = source;
}
return;
} else if (namespace == null) {
if (node.name == 'get-function') {
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sass_migrator
version: 2.0.2
version: 2.0.3
description: A tool for running migrations on Sass files
homepage: https://github.com/sass/migrator

Expand All @@ -15,7 +15,7 @@ dependencies:
js: ^0.6.3
meta: ^1.3.0
node_interop: ^2.0.2
node_io: ^2.2.0
node_io: ^2.3.0
path: ^1.8.0
sass_api: ^9.2.7
source_span: ^1.8.1
Expand Down

0 comments on commit dce67db

Please sign in to comment.