purescript-emacs / purescript-mode

Emacs major mode and related tools for Purescript
20 stars 10 forks source link

lexical-binding breaks decl-scan #25

Open niklas opened 2 weeks ago

niklas commented 2 weeks ago

Hemlo!

Since https://github.com/purescript-emacs/purescript-mode/commit/9a9f55043872b9621286c5e2752f7f09fb07450e the function purescript-ds-create-imenu-index throws an error:

Scanning declarations in Helpers.purs... (  0%)
In ‘Imenu’ source: ‘helm-imenu-candidates’ 
 (void-variable index-imp-alist)

With some creative insertion of (message ..) I managed to find the guilty expression: (symbol-value sym) in line 497 (https://github.com/purescript-emacs/purescript-mode/blob/master/purescript-decl-scan.el#L497).

I am still quite a elisp-noob, so I cannot explain why the index-imp-alist variable is void, because I see it initialized in the (let* ..) in line 463ff.

When I remove the lexical-binding: t in the first line of the file, the error disappears and my helm/imenu declaration list is properly populated.

Emacs Versions tested: 26.X, 29.4, 31.0

Hi-Angel commented 1 week ago

Thank you for the report! Please, in the future when you notice someone introduced a regression (disregarding the project), please CC the author, so they'd be able to get involved.

I fixed the bug in a PR, it's waiting for review. I'm not sure how long it's gonna take though because @kritzcreek seems to have disappeared, and from what I understand there isn't other maintainers… In the meanwhile, you can apply the changes locally if you want by copying from the raw version.

I tested the output of the function before and after the change on one PS file and the hashsums match, the output didn't change. So presumably everything should be okay.