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

Operator '+' cannot be applied to operands of type 'System.Numerics.BigInteger' and 'double' #226

Closed
perlun opened this issue Nov 16, 2021 · 1 comment
Labels
bug Something isn't working as expected
Milestone

Comments

@perlun
Copy link
Collaborator

perlun commented Nov 16, 2021

This is currently broken:

Perlang Interactive REPL Console (0.1.0-dev.181, built from git commit 9480f21)
> (2 ** 32) + 0.01
Unhandled exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Operator '+' cannot be applied to operands of type 'System.Numerics.BigInteger' and 'double'
   at CallSite.Target(Closure , CallSite , Object , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at Perlang.Interpreter.PerlangInterpreter.VisitBinaryExpr(Binary expr) in /home/runner/work/perlang/perlang/src/Perlang.Interpreter/PerlangInterpreter.cs:line 1057
   at Perlang.Expr.Binary.Accept[TR](IVisitor`1 visitor) in /home/runner/work/perlang/perlang/src/Perlang.Common/Expr.cs:line 101
   at Perlang.Interpreter.PerlangInterpreter.Evaluate(Expr expr) in /home/runner/work/perlang/perlang/src/Perlang.Interpreter/PerlangInterpreter.cs:line 827
   at Perlang.Interpreter.PerlangInterpreter.Eval(String source, ScanErrorHandler scanErrorHandler, ParseErrorHandler parseErrorHandler, NameResolutionErrorHandler nameResolutionErrorHandler, ValidationErrorHandler typeValidationErrorHandler, ValidationErrorHandler immutabilityValidationErrorHandler, CompilerWarningHandler compilerWarningHandler) in /home/runner/work/perlang/perlang/src/Perlang.Interpreter/PerlangInterpreter.cs:line 385
   at Perlang.ConsoleApp.Program.Run(String source, CompilerWarningHandler compilerWarningHandler) in /home/runner/work/perlang/perlang/src/Perlang.ConsoleApp/Program.cs:line 352
   at Perlang.ConsoleApp.Program.RunPrompt() in /home/runner/work/perlang/perlang/src/Perlang.ConsoleApp/Program.cs:line 346
   at Perlang.ConsoleApp.Program.<>c__DisplayClass9_0.<MainWithCustomConsole>b__3(ParseResult parseResult, IConsole console) in /home/runner/work/perlang/perlang/src/Perlang.ConsoleApp/Program.cs:line 180
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object , Span`1& , Signature , Boolean , Boolean )
   at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Delegate.DynamicInvoke(Object[] args)
   at System.CommandLine.Invocation.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass16_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass25_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__24_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass11_0.<<UseDebugDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__10_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass14_0.<<UseExceptionHandler>b__0>d.MoveNext()

I tracked this with git bisect quite a bit back, and it seems to have been broken at least since dfa1900, i.e. the first version that built on .NET 5. I don't currently have any .NET Core 3.1 SDK installed so I'm unable to test the older versions (unless I install them manually with perlang-install, hmm...). Suffice to say, this has been broken for a long time.

@perlun perlun added the bug Something isn't working as expected label Nov 16, 2021
@perlun perlun added this to the 0.1.0 milestone Nov 16, 2021
@perlun
Copy link
Collaborator Author

perlun commented Jan 8, 2022

Just like with #229, this now works better as of #237 being merged:

> (2 ** 32) + 0.01
[line 1] Operands must be numbers, not bigint and double
>

This is not perfect, but I can live with it. I don't think we need to be perfect in the 0.1.0 release, but we shouldn't have any (known) things with which you can crash the entire REPL/interpreter at least.

@perlun perlun closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

1 participant