[Refactoring] Variable interpretation from its initializer

Reuse VarDeclaration::getConstInitializer.
fix Issue 10016 - Incorrect error gagging using RefCounted
Merge pull request #1983 from 9rnsr/fix10016

[REG2.063a] Issue 10016 - Incorrect error gagging using RefCounted