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

Fix instrumentation of small map literals. Minor doc updates. #665

Merged

Conversation

FiV0
Copy link
Contributor

@FiV0 FiV0 commented Feb 5, 2020

Map literal instrumentation was relying on some heuristic before.
We use Clojures underlying array-map implementation for small map
literals and fall back to a sorted order of keys if that is not the
case. If this fails as well we simply instrument only the values of
the map in the order they appear in a sequential pass.

This fixes clojure-emacs/cider#2773 for small maps at least.

Before submitting a PR make sure the following things have been done:

  • The commits are consistent with our contribution guidelines
  • You've added tests to cover your change(s)
  • All tests are passing
  • The new code is not generating reflection warnings
  • You've updated the README (if adding/changing middleware)

Map literal instrumentation was relying on some heuristic before.
We use Clojures underlying array-map implementation for small map
literals and fall back to a sorted order of keys if that is not the
case. If this fails as well we simply instrument only the values of
the map in the order they appear in a sequential pass.
@FiV0
Copy link
Contributor Author

FiV0 commented Feb 5, 2020

I haven't yet added any tests as I want to get your feedback first.

;; has specified them in that order. If that fails we fall
;; back to simply instrumenting the values in the order they
;; they appear in the map.
;; This depends on Clojure implementation details.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More than happy to consider other heuristics or if you think this is a bad idea.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is reasonable, although this is something we should probably mention in some "Caveats" section of the debugger, so users are not surprised by the behaviour in different scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the policy once more. I think the best thing is to do nothing if the ordered keys approach fails. I will also start a caveats section in the cider docs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the updated approach.

@bbatsov bbatsov merged commit 36b6287 into clojure-emacs:master Feb 6, 2020
@bbatsov
Copy link
Member

bbatsov commented Feb 6, 2020

Thanks!

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.

Debugger locates forms in map literals incorrectly
2 participants