diff --git a/pico_minify.py b/pico_minify.py index df8fd0a..73cff9c 100644 --- a/pico_minify.py +++ b/pico_minify.py @@ -93,8 +93,11 @@ def analyze_node_post(node): if not to_short and not has_elseif: has_empties, starts_with_do = False, False allow_shorthand = allow_parent_shorthands(node) - + # now check the children + if not allow_child_shorthands(node, node.cond): + allow_shorthand = False + for i, body in enumerate(get_node_bodies(node)): if not allow_child_shorthands(node, body): allow_shorthand = False diff --git a/shrinko.py b/shrinko.py index a460bdb..7ebf8b8 100644 --- a/shrinko.py +++ b/shrinko.py @@ -11,7 +11,7 @@ from picotron_cart import write_cart64_compressed_size, write_cart64_version import argparse -k_version = 'v1.2.3' +k_version = 'v1.2.3b' def SplitBySeps(val): return k_hint_split_re.split(val) diff --git a/test_compare/short-lines.p8 b/test_compare/short-lines.p8 index 42c78c2..33f6e57 100644 --- a/test_compare/short-lines.p8 +++ b/test_compare/short-lines.p8 @@ -15,3 +15,9 @@ end ?"bla",1,2,3,4 n=print"bla" n,l=print"bla2" +if(function()?"hello 1" +return true +end) +()do?"hello 2" +end +if(print"hello 1")?"hello 2" diff --git a/test_compare/short-spaces.p8 b/test_compare/short-spaces.p8 index 3ee560f..febaca9 100644 --- a/test_compare/short-spaces.p8 +++ b/test_compare/short-spaces.p8 @@ -17,3 +17,11 @@ end ?"bla",1,2,3,4 n = print"bla" n, l = print"bla2" + +if (function() ?"hello 1" + return true +end) +() do ?"hello 2" +end + +if (print"hello 1") ?"hello 2" diff --git a/test_compare/short.p8 b/test_compare/short.p8 index 066cae9..63c8a88 100644 --- a/test_compare/short.p8 +++ b/test_compare/short.p8 @@ -10,4 +10,6 @@ end?((function()if e==0do e=1end end)()) ?"bla" ?"bla",1,2,3,4 ?"bla",1,2,3,4 -n=print"bla"n,l=print"bla2" +n=print"bla"n,l=print"bla2"if(function()?"hello 1" +return true end)()do?"hello 2" +end if(print"hello 1")?"hello 2" diff --git a/test_input/short.p8 b/test_input/short.p8 index b289a39..9eb985b 100644 --- a/test_input/short.p8 +++ b/test_input/short.p8 @@ -23,3 +23,15 @@ end print("bla");print("bla",1,2,3,4);print("bla",1,2,3,4) prout = print("bla") prout, prout2 = print("bla2") + +if (function() + print"hello 1" + return true +end) +() then +print"hello 2" +end + +if print"hello 1" then + print"hello 2" +end