mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-31 07:33:01 +00:00 
			
		
		
		
	Validate optional args to import
This commit is contained in:
		| @@ -2,6 +2,7 @@ | ||||
| All notable changes to this project will be documented in this file. | ||||
|  | ||||
| ## Unreleased - ??? | ||||
| - Raise helpful errors for incorrect arguments to `import`. | ||||
| - Allow configuring `JANET_THREAD_LOCAL` during builds to allow multi-threading on unknown compilers. | ||||
| - Make `ffi/write` append to a buffer instead of insert at 0 by default. | ||||
| - Add `os/getpid` to get the current process id. | ||||
|   | ||||
| @@ -3185,8 +3185,13 @@ | ||||
|   value to bypass the module cache. Use `:only [foo bar baz]` to only import | ||||
|   select bindings into the current environment.`` | ||||
|   [path & args] | ||||
|   (assertf (even? (length args)) "args should have even length: %n" args) | ||||
|   (def ps (partition 2 args)) | ||||
|   (def argm (mapcat (fn [[k v]] [k (case k :as (string v) :only ~(quote ,v) v)]) ps)) | ||||
|   (def argm | ||||
|     (mapcat (fn [[k v]] | ||||
|               (assertf (keyword? k) "expected keyword, got %s: %n" (type k) k) | ||||
|               [k (case k :as (string v) :only ~(quote ,v) v)]) | ||||
|             ps)) | ||||
|   (tuple import* (string path) ;argm)) | ||||
|  | ||||
| (defmacro use | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 sarna
					sarna