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

Brackets with nested functions that have multiple parameters #2

Open
jersonal-com opened this issue Sep 7, 2023 · 1 comment
Open

Comments

@jersonal-com
Copy link

Thanks a lot for the great library.

I am having trouble when nesting functions. I defined a simple minimum function that takes 2 parameters and returns the lower of the two (see below). When used in isolation the function works as expected.

When using min(1,min(2,3)) (or any other case where one function is nested into another one) I get a BrackedNotClosedException (line 438 in parser.dart).

It seems that the parser separates min(2, as a second parameter to the first min function.

class MathFunctionMin implements MathDefinitionFunctionFreeformImplemented {
  @override
  final name = 'min';
  @override
  final minArgumentsCount = 2;
  @override
  final maxArgumentsCount = 2;

  @override
  num calc(
      List<MathNode> args,
      MathVariableValues values, {
        required MathCustomFunctionsImplemented customFunctions,
      }) {
    return min(args[0].calc(values, customFunctions: customFunctions),
      args[1].calc(values, customFunctions: customFunctions),
    );
  }

  @override
  bool hasSameName(String other) {
    return other == name;
  }

  @override
  bool isCompatible(MathDefinitionFunctionFreeform other) {
    return hasSameName(other.name) &&
        minArgumentsCount == other.minArgumentsCount &&
        maxArgumentsCount == other.maxArgumentsCount;
  }

  const MathFunctionMin();
}
@Sominemo
Copy link
Owner

Sominemo commented Oct 31, 2023

Hello and sorry for my late reply!

I started working on this issue a while ago but it requires a considerable rewrite, so it took more time than expected and got pushed away by some other urgent tasks.

Consider this reply as an indicator that I've seen your report and I value it a lot, I'll return to fixing it ASAP, thank you for filing the issue!

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