[compiler] Fix some invalid generation of logic_expression

Previously, the code generated for function of arity 0 is incorrect, as
it adds a ,. The new code is simpler and correct for function of any
arities.