It seems that you are basically asking about exporting and when something needs to be exported. Let's look at each of your examples:
VAR=hello; echo $VAR: these are two commands, run in the same shell session. Since we are in the same session, the first variable assignment is enough and there is no need toexportanything.VAR=hello :; echo $VAR: here too we have two commands in the same shell session but in this case, the variable was explicitly only set for the duration of the:command. So here, you didn't actually set the variable in your shell session, you only set it for that one command. So when you get back to the shell, the variable is unset hence the echo prints an empty line.VAR=hello; echo $VAR; bash -c 'echo $VAR': here we have one shell session in which you runVAR=helloandecho $VAR. You then start a new shell session, which will therefore not inherit unexported variables, and in that second session, theecho $VARprints nothing. This is where exporting would have made a difference:$ var=hello; bash -c 'echo $var' $ export var=hello; bash -c 'echo $var' hello
Though as was pointed out in comments, : is a "special built-in", and so according to POSIX, the result of the assignment in VAR=hello : should be visiblepersist in the shell environment after : returns. Bash doesn't do that in normal mode though, but does in POSIX mode, as does pretty much any other POSIX shell.
So unset VAR; VAR=hello :; echo "$VAR" does print hello in POSIX-mode bash (bash called with -o posix or --posix or with sh or anything/sh as its argv[0] or with POSIXLY_CORRECT or SHELLOPTS=posix in its environment), dash, oryash, ksh or zsh in sh or ksh emulation. That would be different with e.g. true instead of :, since it's just a regular command (builtin or not).