Skip to content
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

NullReferenceException when trying to default-initialize array argument #29

Closed
yeputons opened this issue Oct 9, 2021 · 1 comment
Closed
Assignees

Comments

@yeputons
Copy link

yeputons commented Oct 9, 2021

The following code saved to x.ci:

public static class Test
{
    public static void Run(int[]# arr = new int[10]) {
    }
}

produces the following error when running cito x.ci -o x.py compiled from 5e518d3:

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Foxoft.Ci.GenBase.Visit(CiPrefixExpr expr, CiPriority parent) in F:\cito\GenBase.cs:line 840
   at Foxoft.Ci.GenPySwift.Visit(CiPrefixExpr expr, CiPriority parent) in F:\cito\GenPySwift.cs:line 112
   at Foxoft.Ci.GenPy.Visit(CiPrefixExpr expr, CiPriority parent) in F:\cito\GenPy.cs:line 254
   at Foxoft.Ci.CiPrefixExpr.Accept(CiVisitor visitor, CiPriority parent) in F:\cito\CiTree.cs:line 435
   at Foxoft.Ci.GenBase.WriteCoercedInternal(CiType type, CiExpr expr, CiPriority parent) in F:\cito\GenBase.cs:line 612
   at Foxoft.Ci.GenBase.WriteCoerced(CiType type, CiExpr expr, CiPriority parent) in F:\cito\GenBase.cs:line 633
   at Foxoft.Ci.GenBase.WriteCoercedExpr(CiType type, CiExpr expr) in F:\cito\GenBase.cs:line 754
   at Foxoft.Ci.GenBase.WriteVarInit(CiNamedValue def) in F:\cito\GenBase.cs:line 765
   at Foxoft.Ci.GenBase.WriteParameters(CiMethod method, Boolean first, Boolean defaultArguments) in F:\cito\GenBase.cs:line 1340
   at Foxoft.Ci.GenPy.Write(CiMethod method) in F:\cito\GenPy.cs:line 1075
   at Foxoft.Ci.GenPy.Write(CiClass klass) in F:\cito\GenPy.cs:line 1118
   at Foxoft.Ci.GenPy.Write(CiProgram program) in F:\cito\GenPy.cs:line 1158
   at Foxoft.Ci.CiTo.Main(String[] args) in F:\cito\CiTo.cs:line 155

Context: I was trying to see how Python's mutable default arguments are handled.

@pfusik pfusik self-assigned this Oct 9, 2021
@pfusik pfusik closed this as completed in ff054d4 Oct 9, 2021
@pfusik
Copy link
Collaborator

pfusik commented Oct 9, 2021

Error checking is citos weak point. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants