updated the compiler to make 'do' handling more consistent with {}
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -16,7 +16,6 @@ check_SCRIPTS = \
|
||||
check_ERRORS = \
|
||||
call-5001.err \
|
||||
class-5001.err \
|
||||
do-5001.err \
|
||||
feed-5001.err \
|
||||
mlist-5001.err \
|
||||
var-5001.err \
|
||||
|
@ -488,7 +488,6 @@ check_SCRIPTS = \
|
||||
check_ERRORS = \
|
||||
call-5001.err \
|
||||
class-5001.err \
|
||||
do-5001.err \
|
||||
feed-5001.err \
|
||||
mlist-5001.err \
|
||||
var-5001.err \
|
||||
|
@ -1,13 +0,0 @@
|
||||
## if `do` is not enclosed in `( )`, variable declaration is prohibited
|
||||
do { | k | set k 10 };
|
||||
do | k | {set k 10;}; ##ERROR: syntax error - variable declaration disallowed
|
||||
|
||||
---
|
||||
|
||||
## if `do` is not enclosed in `( )`, it supports only the limited number of expressions.
|
||||
|
||||
do ; ## this is ok
|
||||
|
||||
do 1; ## this is ok
|
||||
|
||||
do { set k 10; printf "k=%d\n" k; } { set k 20; printf "k=%d\n" k; }; ##ERROR: syntax error - more than one expression after do
|
@ -194,3 +194,25 @@ throw ##ERROR: syntax error - no value or expression after 'throw'
|
||||
---
|
||||
|
||||
throw throw ##ERROR: syntax error - 'throw' prohibited in this context
|
||||
|
||||
---
|
||||
|
||||
class X {
|
||||
x := {
|
||||
|a| ##ERROR: syntax error - variable declaration disallowed in class init scope
|
||||
a := 20
|
||||
}
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
do ; ## this is ok
|
||||
do 1; ## this is ok
|
||||
|
||||
k := (do 1 2 3); ## ok too
|
||||
## do doesn't allow variable declaration
|
||||
do { | k | set k 10 };
|
||||
do | k | {set k 10;}; ##ERROR: syntax error - variable declaration disallowed in 'do' context
|
||||
|
||||
---
|
||||
k := (do | k | {set k 10;}) ##ERROR: syntax error - variable declaration disallowed in 'do' context
|
||||
|
@ -85,8 +85,8 @@ if (nqv? R false) (print "ERROR: R is not false\n") \
|
||||
else (printf "OK: %O\n" R)
|
||||
|
||||
set v #(
|
||||
(do |a b| (set a 10) (set b 20) (+ a b) )
|
||||
(do |a b| (set a 11) (set b 21) (+ a b) )
|
||||
{ |a b| set a 10; set b 20; + a b }
|
||||
{ |a b| set a 11; set b 21; + a b }
|
||||
999
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user