-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NCCS incorrectly treating some methods as extern #759
Comments
@shargon Can you test compiling the contracts in this zip file using nccs 3.3.0? There are two single-file contracts in this zip file.
AssertContract is a simple contract with a single method demonstrating the failure to compile a contract that calls the public class AssertContract : SmartContract
{
public static void TestAssertWithMessage()
{
ExecutionEngine.Assert(1 == 2, "Bad Math");
}
} SomeToken is the simplest public class SomeToken : TokenContract
{
public override byte Decimals() => 10;
public override string Symbol() => "SOME";
} |
For AssertContract, nccs is throwing in public void Convert(SemanticModel model)
{
// when converting ExecutionEngine.Assert(bool, string),
// ContainingType.DeclaringSyntaxReferences.IsEmpty is true
if (Symbol.IsExtern || Symbol.ContainingType.DeclaringSyntaxReferences.IsEmpty)
{
if (Symbol.Name == "_initialize")
{
ProcessStaticFields(model);
if (context.StaticFieldCount > 0)
{
_instructions.Insert(0, new Instruction
{
OpCode = OpCode.INITSSLOT,
Operand = new[] { (byte)context.StaticFieldCount }
});
}
}
else
{
// Symbol.Name is "Assert" so we end up here.
// But the Assert overload we're calling isn't extern so ConvertExtern fails
ConvertExtern();
}
}
// remainder of Convert method omitted for clarity |
Note, SomeToken contract ends up in |
FYI, it appears both of these contracts also fail to compile under nccs v3.1.0 |
I think I know what's going on here. In nccs, depending on the command line parameters the execution path goes thru either The Since the SmartContract Framework source code is not available when nccs goes down the CompileSources path, then To solve this, I think we need to:
|
FYI, I'm going to tackle this bug after I do #760 |
If I try and compile a contract with
ExecutionEngine.Assert(false, "message");
statement, C# compilation succeeds but nccs compilation failscc @erikzhang
The text was updated successfully, but these errors were encountered: