fix: handle partial class compilation with correct SemanticModel#1488
Merged
fix: handle partial class compilation with correct SemanticModel#1488
Conversation
Member
|
I will test asap |
Member
|
Sometimes master, Sometimes master-n3 🫣 |
Contributor
Author
Sigh,,,,, well.... |
- Add SemanticModelExtensions.GetModelForNode() helper method - Fix Expression.cs to check syntax tree before GetConstantValue - Fix InvocationExpression.cs to get correct model for GetSymbolInfo - Fix SourceConvert.cs to get correct model for GetTypeInfo This fixes NC5001 errors when compiling contracts with partial classes (e.g., Example.SmartContract.NFT) where syntax nodes may come from different syntax trees than the current semantic model. Closes #1363
Tests the fix for issue #1363 where syntax nodes from different syntax trees caused NC5001 errors during compilation. New tests cover: - Cross-file method invocations in partial classes - Expression-bodied members using constants from other files - Complex expressions using both constants and methods across files
964372b to
a015cbe
Compare
shargon
approved these changes
Jan 27, 2026
ajara87
reviewed
Jan 27, 2026
Comment on lines
+35
to
+38
| if (!model.SyntaxTree.Equals(expression.SyntaxTree)) | ||
| { | ||
| model = model.Compilation.GetSemanticModel(expression.SyntaxTree); | ||
| } |
Contributor
Author
There was a problem hiding this comment.
Thank you for your suggestion, applied.
Apply review suggestion to use the GetModelForNode extension method instead of inline syntax tree check. This allows constant evaluation to work across partial class files.
Jim8y
added a commit
that referenced
this pull request
Jan 28, 2026
* Update neo submodule to master-n3 (#1453) Co-authored-by: Neo Dev Bot <dev@neo.local> * Use stable framework package in templates (#1456) * Add: FindOptions.Backwards definition (#1458) * Add: IsContract for ContractManagement (#1454) (#1455) Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com> * CI: run on master-n3 (#1459) * Update neo (#1463) * Upgrade devpack to Neo v3.9.0 (#1464) * Upgrade devpack to Neo v3.9.0 * Restore manifest version in test artifacts * Add: comment doc for Framework.Services (#1460) (#1467) * Fix: remove many compiler warnings (#1461) (#1469) * Reorder (#1472) * Fix CS0067 warning in artifacts (#1474) * Avoid CS0067 in artifacts * one more * Add: comments doc for ContractMethod CallFlags (#1479) * Add reference (#1476) * docs: Clarify Base58CheckDecode FAULT behavior in UInt160.Parse (#1483) Update documentation to warn that invalid Base58Check addresses will cause execution to FAULT (abort) rather than throw a catchable exception. Fixes #1443 * fix: HexStringInterpreter regex should only accept hex characters (#1484) Change regex from [a-zA-Z0-9_] to [a-fA-F0-9] to properly validate hexadecimal strings (0-9, a-f, A-F only). Fixes #1264 * docs: Add optimizer documentation (#1481) * docs: Add optimizer documentation Document the bytecode optimization strategies including: - Peephole optimization - Jump compression - Reachability analysis - Miscellaneous optimizations Also includes architecture overview and usage instructions. * docs: add OptimizationType enum options to optimizer documentation * fix(compiler): extend division overflow check and improve temp file security (#1485) * fix(compiler): extend division overflow check to IntPtr type - Add comprehensive documentation for CheckDivideOverflow method - Extend overflow check to include IntPtr (nint) type - Use BigInteger for consistent handling of min values - Add clear comments explaining which types need/don't need overflow checks Fixes HIGH-002 from security audit * test: add unit tests for division overflow fix Demonstrates the IntPtr (nint) division overflow issue and fix: - Before fix: nint.MinValue / -1 would silently overflow - After fix: properly throws in checked context Tests cover Int32, Int64, IntPtr, and BigInteger division scenarios. * fix: remove unsupported nint/nuint types from tests Neo compiler does not support nint/nuint (IntPtr/UIntPtr) types. Removed IntPtr handling from division overflow check and tests. * test: add testing artifacts for division overflow and shift contracts - Add Contract_DivisionOverflow.cs testing artifact - Update Contract_shift.cs with new shift methods All 938 tests pass locally. * chore: revert neo submodule to master-n3 version * fix: Support Event?.Invoke() conditional invocation pattern (#1482) Add support for invoking events using the null-conditional operator. When calling Event?.Invoke(...), the compiler now correctly recognizes this as an event invocation and emits the appropriate System.Runtime.Notify call. Fixes #1093 * Update examples for Neo v3.9 (#1465) * Update examples for v3.9 * chore: Remove example nef and manifest artifacts Remove compiled artifacts from examples as requested in PR review. These files should be generated during build, not committed. * refactor: replace neo submodule with NuGet package references (Neo 3.9.1) (#1489) * refactor: replace neo submodule with NuGet package references (Neo 3.9.1) - Remove neo submodule dependency - Update project references to use NuGet packages: - Neo 3.9.1 - Neo.Extensions 3.9.1 - Neo.IO 3.9.1 - Neo.Json 3.9.1 - Simplify CI workflow by removing submodule-related version extraction - Fix PublishPackage job that was failing due to empty VERSION_NEO variable * fix: workflow should support both master and master-n3 branches * fix: restore Release job in workflow * fix: remove neo submodule projects from solution file * fix: handle partial class compilation with correct SemanticModel (#1488) * fix: handle partial class compilation with correct SemanticModel - Add SemanticModelExtensions.GetModelForNode() helper method - Fix Expression.cs to check syntax tree before GetConstantValue - Fix InvocationExpression.cs to get correct model for GetSymbolInfo - Fix SourceConvert.cs to get correct model for GetTypeInfo This fixes NC5001 errors when compiling contracts with partial classes (e.g., Example.SmartContract.NFT) where syntax nodes may come from different syntax trees than the current semantic model. Closes #1363 * test: add unit tests for partial class cross-file compilation Tests the fix for issue #1363 where syntax nodes from different syntax trees caused NC5001 errors during compilation. New tests cover: - Cross-file method invocations in partial classes - Expression-bodied members using constants from other files - Complex expressions using both constants and methods across files * refactor: use GetModelForNode helper in TryConvertConstant Apply review suggestion to use the GetModelForNode extension method instead of inline syntax tree check. This allows constant evaluation to work across partial class files. --------- Co-authored-by: Jimmy <jimmy@r3e.network> Co-authored-by: Neo Dev Bot <dev@neo.local> Co-authored-by: Will <201105916+Wi1l-B0t@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix NC5001 compiler errors when compiling contracts with partial classes (e.g., Example.SmartContract.NFT).
Changes
Closes #1363