M fugue.janet => fugue.janet +8 -15
@@ 1,12 1,3 @@
-(defn- compiler-emit
- [level msg]
- (let [source (or (dyn :current-file) "n/a")
- [l c] (tuple/sourcemap (dyn :macro-form ()))]
- (eprintf "%s:%i:%i: [%s] %s" source l c level msg)))
-
-(defn- compiler-warn [msg] (compiler-emit "WARNING" msg))
-(defn- compiler-info [msg] (compiler-emit "INFO" msg))
-
#
# Compile-time field access
#
@@ 68,7 59,7 @@
true (if-let [reg-key (string (dyn :current-file) "-" obj)
listing (registry-fields reg-key)]
listing
- (compiler-warn (string "no prototype definition found for " obj)))))
+ (maclintf :normal "no prototype definition found for %s" (string obj)))))
#
# Field Validation
@@ 90,10 81,12 @@
(defn- warn-proto-method-shadow
[name proto]
(when (index-of (keyword name) (comp-aware-fields proto))
- (compiler-warn
- (string/format "you are defining a method named %s on the prototype %s; there is a field of the same name on that prototype."
- (string name)
- (string proto)))))
+ (maclintf
+ :normal
+ (string "you are defining a method named %s on the prototype %s; "
+ "there is a field of the same name on that prototype.")
+ (string name)
+ (string proto))))
#
# defproto Forms
@@ 458,7 451,7 @@
(upscope
(let [current-binding (dyn name)]
@[(unless (and current-binding (function? (current-binding :value)))
- (compiler-info (string "Defining generic function for method " name "..."))
+ (maclintf :strict "Defining generic function for method %s ..." (string name))
(defgeneric* name nil args raise-sentinel))
(let [method-name (keyword name)
M test/fugue.janet => test/fugue.janet +14 -9
@@ 384,13 384,15 @@
(fugue/defproto ToShadowField nil name {})
(deftest defmethod-warning
- (def buffer @"")
- (with-dyns [:err buffer]
+ (def buffer @[])
+ (with-dyns [:macro-lints buffer]
(apply fugue/defmethod '[name ToShadowField [x] "ok"]))
- (is (string/has-suffix?
- "you are defining a method named name on the prototype ToShadowField; there is a field of the same name on that prototype.\n"
- buffer)))
+ (let [[[level l c msg]] buffer]
+ (is (== :normal level))
+ (is (==
+ "you are defining a method named name on the prototype ToShadowField; there is a field of the same name on that prototype."
+ msg))))
# Define generic so we get a clean stdout
(fugue/defgeneric height [x] :ok)
@@ 398,12 400,15 @@
(deftest defmethod-warning-in-test
(fugue/defproto ShadowInTest nil height {})
- (def buffer @"")
- (with-dyns [:err buffer]
+ (def buffer @[])
+ (with-dyns [:macro-lints buffer]
(apply fugue/defmethod '[height ShadowInTest [x] "ok"]))
- (is (string/has-suffix? "you are defining a method named height on the prototype ShadowInTest; there is a field of the same name on that prototype.\n"
- buffer)))
+ (let [[[level l c msg]] buffer]
+ (is (== :normal level))
+ (is (==
+ "you are defining a method named height on the prototype ShadowInTest; there is a field of the same name on that prototype."
+ msg))))
(deftest defmulti-in-test
(fugue/defmulti in-test-multi [:number] [n] (inc n))