fix Issue 9806 - assertion failure in struct.c:668

- Save Scope object to resolve forward references
- Do constant folding in template value argument comparison

Additional:
Add assertions to check AST identity in `ClassDeclaration::semantic` and `InterfaceDeclaration::semantic`.
Merge pull request #1822 from 9rnsr/fix9806

[REG2.063a] Issue 9806 - assertion failure in struct.c:668