refactor-nrepl icon indicating copy to clipboard operation
refactor-nrepl copied to clipboard

Analyzer fn* error on AST building

Open arichiardi opened this issue 2 years ago • 3 comments

Hey folks, I am mostly seeking a way to debug and understand what the problem is, just started using refactor-nrepl again after a while :smile:

Expected behavior

It expect the AST to be built.

Actual behavior

It throws an error

Steps to reproduce the problem

Sorry, don't have that yet, however the stack trace I get is

Syntax error compiling fn* at (file:/home/cokap/git/cohesic/acuity/appserver/src/com/cohesic/acuity/core2/reporting/interfaces/repository.clj:1:20)
java.lang.IllegalStateException: refactor-nrepl is unable to build an AST for com.cohesic.acuity.core2.reporting.interfaces.diagnostic-report-repository. tools.analyzer encountered the following problem: Syntax error compiling fn* at (file:/home/cokap/git/cohesic/acuity/appserver/src/com/cohesic/acuity/core2/reporting/interfaces/diagnostic_report_repository.clj:1:20).
	at refactor_nrepl.analyzer$throw_ast_in_bad_state.invokeStatic(analyzer.clj:111)
	at refactor_nrepl.analyzer$throw_ast_in_bad_state.invoke(analyzer.clj:108)
	at refactor_nrepl.analyzer$ns_ast.invokeStatic(analyzer.clj:127)
	at refactor_nrepl.analyzer$ns_ast.invoke(analyzer.clj:115)
	at refactor_nrepl.find.find_symbol$find_symbol_in_file$fn__218357.invoke(find_symbol.clj:108)
	at refactor_nrepl.find.find_symbol$find_symbol_in_file.invokeStatic(find_symbol.clj:108)
	at refactor_nrepl.find.find_symbol$find_symbol_in_file.invoke(find_symbol.clj:106)
	at refactor_nrepl.find.find_symbol$find_global_symbol$fn__218370.invoke(find_symbol.clj:160)
	[CUT]

The file does not contain much, I report here what might be important (or not?):

(ns com.cohesic.acuity.core2.reporting.interfaces.repository
  (:require
   [clojure.spec.alpha :as s]))

(defprotocol Repository
  "Store and retrieve."
  :extend-via-metadata true
  (add
   [repository insert-params]
   "Add to the repository.")
  (update
   [repository update-params]
   "Update."))

;; following many `s/def`s
(s/def ::repository any?)

Environment & Version information

clj-refactor.el and refactor-nrepl version information

clj-refactor 3.5.2, refactor-nrepl 3.5.2

CIDER version information

master

Emacs version

GNU Emacs 28.1.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6) of 2022-04-27

arichiardi avatar May 19 '22 23:05 arichiardi

Isn't it another namespace the one at fault? diagnostic_report_repository.clj

vemv avatar May 20 '22 06:05 vemv

@vemv yes sorry I did not change one small thing, let me fix that.

The one I am showing there is the right code though.

arichiardi avatar May 20 '22 15:05 arichiardi

A Syntax error compiling [...] is generally always followed by a caused by: and then the cause of the exception, please make sure to retrieve the whole stacktrace

vemv avatar May 20 '22 16:05 vemv

I wasn't able to reproduce this. I'll add a test case to refactor-nrepl.analyzer-test with that defprotocol (which is worth testing because it shadows update).

Do feel free to reopen the issue you manage to obtain a stacktrace.

vemv avatar Aug 21 '22 18:08 vemv