mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Update short-fn to fix #1123
Symbols are renamed on expansion to avoid the issue.
This commit is contained in:
		| @@ -2,6 +2,8 @@ | |||||||
| All notable changes to this project will be documented in this file. | All notable changes to this project will be documented in this file. | ||||||
|  |  | ||||||
| ## Unreleased - ??? | ## Unreleased - ??? | ||||||
|  | - Various bug fixes | ||||||
|  | - Make nested short-fn's behave a bit more predictably (it is still not recommended to nest short-fns). | ||||||
| - Add `os/strftime` for date formatting. | - Add `os/strftime` for date formatting. | ||||||
| - Fix `ev/select` on threaded channels sometimes live-locking. | - Fix `ev/select` on threaded channels sometimes live-locking. | ||||||
| - Support the `NO_COLOR` environment variable to turn off VT100 color codes in repl (and in scripts). | - Support the `NO_COLOR` environment variable to turn off VT100 color codes in repl (and in scripts). | ||||||
|   | |||||||
| @@ -2209,6 +2209,7 @@ | |||||||
|   (defn saw-special-arg |   (defn saw-special-arg | ||||||
|     [num] |     [num] | ||||||
|     (set max-param-seen (max max-param-seen num))) |     (set max-param-seen (max max-param-seen num))) | ||||||
|  |   (def prefix (gensym)) | ||||||
|   (defn on-binding |   (defn on-binding | ||||||
|     [x] |     [x] | ||||||
|     (if (string/has-prefix? '$ x) |     (if (string/has-prefix? '$ x) | ||||||
| @@ -2216,22 +2217,24 @@ | |||||||
|         (= '$ x) |         (= '$ x) | ||||||
|         (do |         (do | ||||||
|           (saw-special-arg 0) |           (saw-special-arg 0) | ||||||
|           '$0) |           (symbol prefix '$0)) | ||||||
|         (= '$& x) |         (= '$& x) | ||||||
|         (do |         (do | ||||||
|           (set vararg true) |           (set vararg true) | ||||||
|           x) |           (symbol prefix x)) | ||||||
|         :else |         :else | ||||||
|         (do |         (do | ||||||
|           (def num (scan-number (string/slice x 1))) |           (def num (scan-number (string/slice x 1))) | ||||||
|           (if (nat? num) |           (if (nat? num) | ||||||
|             (saw-special-arg num)) |             (do | ||||||
|           x)) |               (saw-special-arg num) | ||||||
|  |               (symbol prefix x)) | ||||||
|  |             x))) | ||||||
|       x)) |       x)) | ||||||
|   (def expanded (macex arg on-binding)) |   (def expanded (macex arg on-binding)) | ||||||
|   (def name-splice (if name [name] [])) |   (def name-splice (if name [name] [])) | ||||||
|   (def fn-args (seq [i :range [0 (+ 1 max-param-seen)]] (symbol '$ i))) |   (def fn-args (seq [i :range [0 (+ 1 max-param-seen)]] (symbol prefix '$ i))) | ||||||
|   ~(fn ,;name-splice [,;fn-args ,;(if vararg ['& '$&] [])] ,expanded)) |   ~(fn ,;name-splice [,;fn-args ,;(if vararg ['& (symbol prefix '$&)] [])] ,expanded)) | ||||||
|  |  | ||||||
| ### | ### | ||||||
| ### | ### | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose