Handle undef refs in jl_copy_ast, fixes #9475

[ci skip] checked on branch fix9475
passed osx
passed linux except for some network issue cloning package.