added a double lambda test case
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
49ad657544
commit
081c6d1874
11
lib/read.c
11
lib/read.c
@ -1335,13 +1335,12 @@ static int feed_process_token (hcl_t* hcl)
|
|||||||
case HCL_TOK_LPAREN: /* ( */
|
case HCL_TOK_LPAREN: /* ( */
|
||||||
#if defined(HCL_LANG_AUTO_FORGE_XLIST_ALWAYS)
|
#if defined(HCL_LANG_AUTO_FORGE_XLIST_ALWAYS)
|
||||||
/* with this feature on, you must not enclose an expression with ()
|
/* with this feature on, you must not enclose an expression with ()
|
||||||
* at the top-level or a the block level. If you do, it is interpreted as
|
* at the beginning of the top-level or at the beginning of a the block level.
|
||||||
* double exuection, meaning the return value of the expression is
|
* If you do enclose an expression with an outer () there, it is interpreted as
|
||||||
* called again.
|
* double calls, meaning the return value of the expression is called again.
|
||||||
*
|
* for example, '(+ 10 20)' as a leading expression is like '((+ 10 20))'.
|
||||||
* (+ 10 20) as a leading expression is like ((+ 10 20)).
|
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
* However, it can be a bit confusing:
|
* It is useful but a bit confusing:
|
||||||
* defun x(a) { return (fun(b) { return (+ a b) }) }
|
* defun x(a) { return (fun(b) { return (+ a b) }) }
|
||||||
* printf "%d\n" ((x 10) 20) ## excplicit outer () is required here
|
* printf "%d\n" ((x 10) 20) ## excplicit outer () is required here
|
||||||
* (x 10) 30 ## explicit outer () must not be used here
|
* (x 10) 30 ## explicit outer () must not be used here
|
||||||
|
21
t/fun-01.hcl
21
t/fun-01.hcl
@ -18,7 +18,16 @@ defun mkfun(t) {
|
|||||||
return (fun(c) {
|
return (fun(c) {
|
||||||
return (+ t c);
|
return (+ t c);
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
defun mkfund(t) {
|
||||||
|
return {fun(c) {
|
||||||
|
return (fun(d) {
|
||||||
|
##return (d + c t) ## this causes assertion failure.
|
||||||
|
return (d + c t)
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
f := (mkfun 20);
|
f := (mkfun 20);
|
||||||
set k (f 50);
|
set k (f 50);
|
||||||
@ -38,7 +47,9 @@ if (k = 50) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
k := {
|
k := {
|
||||||
(mkfun 20) 30
|
## the return value of this expression is ignored
|
||||||
|
(mkfun 20) 30 ## having comment here cause an issue...
|
||||||
|
## the return value of this expression is the return value of the block expression
|
||||||
(mkfun 20) 40
|
(mkfun 20) 40
|
||||||
}
|
}
|
||||||
if (k = 60) {
|
if (k = 60) {
|
||||||
@ -47,6 +58,12 @@ if (k = 60) {
|
|||||||
printf "ERROR - %d\n" k
|
printf "ERROR - %d\n" k
|
||||||
};
|
};
|
||||||
|
|
||||||
|
k := (((mkfund 10) 40) 30)
|
||||||
|
if (k = 80) {
|
||||||
|
printf "OK - %d\n" k
|
||||||
|
} else {
|
||||||
|
printf "ERROR - %d\n" k
|
||||||
|
};
|
||||||
## --------------------------------------
|
## --------------------------------------
|
||||||
|
|
||||||
defclass A | a b c | {
|
defclass A | a b c | {
|
||||||
|
1
t/run.sh
1
t/run.sh
@ -1,5 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
## use a subshell to execute the actual program in case the
|
## use a subshell to execute the actual program in case the
|
||||||
## program crashes or exits without an error message.
|
## program crashes or exits without an error message.
|
||||||
|
echo RUN "[$@]"
|
||||||
($@ 2>&1 || echo "ERROR: exited with $?") | grep -E '^ERROR:' && exit 1
|
($@ 2>&1 || echo "ERROR: exited with $?") | grep -E '^ERROR:' && exit 1
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user