Introduce StaticType::Variadic for variadic parameters
This commit introduces `StaticType::Variadic` to represent variadic parameter types in function signatures. This allows for more precise type checking of functions that accept a variable number of arguments, such as arithmetic operators. Previously, variadic functions were handled using `StaticType::Any`, which was too permissive and could lead to runtime errors. The new `Variadic` type enforces that all arguments must conform to a specified inner type. Changes include: - Adding `StaticType::Variadic` to `src/ast/types.rs`. - Updating the type checker to handle `Variadic` types correctly when unifying with tuples or single arguments. - Modifying built-in functions like arithmetic operators to use `Variadic` for their parameter types. - Improving error messages for function call mismatches to be more specific. - Adding a new test case to ensure arithmetic type mismatches are caught at compile time. - A new example `data_stream_pipe_buffered.myc` is added. - The `HMA.myc` example now has a `Skip: output` directive.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
;; Benchmark: 98.9us
|
||||
;; Benchmark-Repeat: 22
|
||||
;; Skip: output
|
||||
(do
|
||||
;; make-sma Factory (O(1))
|
||||
(def make-sma
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
;; Skip: data output to stdout
|
||||
(do
|
||||
(def EURUSD (create-m1-stream "EURUSD" (date "2020-01-03 09:30:00") (date "2020-01-03 10:00:00")))
|
||||
(def GER40 (create-m1-stream "GER40" (date "2020-01-03 09:30:00") (date "2020-01-03 10:00:00")))
|
||||
|
||||
(def cnt 1)
|
||||
|
||||
(pipe-buffered 2 [EURUSD GER40]
|
||||
(fn [eu ge]
|
||||
(do
|
||||
(def dax (.close (ge 0)))
|
||||
(def eur (- dax (ge 1)))
|
||||
(print cnt ": dax=" eur " (" (/ eur (.close (eu 0))) "$)" )
|
||||
(assign cnt (+ cnt 1))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user