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

Remove dead code in the extension store #2129

Merged
merged 1 commit into from
Nov 3, 2023
Merged

Remove dead code in the extension store #2129

merged 1 commit into from
Nov 3, 2023

Conversation

stof
Copy link
Contributor

@stof stof commented Oct 30, 2023

The sources Map will never contain extension.extender as it is an Extender object, not a ComplexSelector.
I updated that by assuming that the comment just above it is true and that the selector should actually be removed.
An alternative could be to remove that line of code entirely, preserving the current behavior where nothing is removed.

The dart compiler does not catch this mistake as Map.remove allows passing any object, not just objects matching the key type.

I caught this when porting that code to PHP for the Scssphp project, where phpstan (the PHP static analyzer we use) has a different signature for the storage we use, requiring a valid key type.

@jathak
Copy link
Member

jathak commented Oct 30, 2023

Could you look into the failing specs?

@stof
Copy link
Contributor Author

stof commented Oct 31, 2023

Based on those failures, maybe not removing the selector is the right behavior, and we should remove the line that was doing nothing.
I'd like to have @nex3's opinion on this as the extend code is quite complex.

@nex3
Copy link
Contributor

nex3 commented Oct 31, 2023

The change in spec/directives/extend/pseudo/into_pseudo/extends_after looks potentially desirable to me, but it's not obvious why this was actually necessary so I'd say just rip out the dead code. We can dive deep into a fix later if we find a broken case.

The key being removed could not exist in the map as it is not even the
same type than keys.
@stof stof changed the title Fix the removal of the selector in the extension store Remove dead code in the extension store Nov 2, 2023
@stof
Copy link
Contributor Author

stof commented Nov 2, 2023

@nex3 I updated the PR to only remove the dead code.

@nex3 nex3 merged commit 54caf19 into sass:main Nov 3, 2023
44 checks passed
@stof stof deleted the patch-1 branch November 6, 2023 10:38
jgerigmeyer added a commit to oddbird/dart-sass that referenced this pull request Nov 17, 2023
* feature.color-4:
  Poke CI
  Update link to Node.js releases page (sass#2131)
  Write implementation documentation (sass#2042)
  Remove dead code (sass#2129)
  Add compatibility with Node.js 21.0.0 (sass#2128)
  Bump lints from 2.1.1 to 3.0.0 (sass#2126)
  Bump dartdoc from 6.3.0 to 7.0.0 (sass#2118)
  Cut a release (sass#2120)
  Update pubspec and changelog for sass/embedded-host-node#257 (sass#2116)
  Fix crash in browser when running alongside NextJS (sass#2114)
  Cut another release (sass#2111)
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

Successfully merging this pull request may close these issues.

None yet

3 participants