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

BUG: Ternary operator in DS def if statement busts compiler #9244

Open
ThomasMahon opened this Issue Nov 13, 2018 · 1 comment

Comments

Projects
None yet
3 participants
@ThomasMahon
Copy link

ThomasMahon commented Nov 13, 2018

Dynamo version

1.3.3

Operating system

Win 10

What did you do?

A simple def in DS with some if statements and a ternary operator.

What did you expect to see?

For DS to break without any rhyme or reason, like it usually does.

What did you see instead?

I saw exactly what I expected, another busted feature of the language. No warnings. No exceptions. Where's the bin?...

Try it for yourself:

def MyDef(x : double)
{
	return = [Imperative]
	{
		if (x <= 100.0)
		{
			divisor = 10.0;
			number = Math.Ceiling(x / divisor) * divisor;
			return = number < 20.0 ? 20.0 : number;
		}
		else if (x <= 250.0) // No need to check if its greater than 100 otherwise it would pass the first if statement
		{
			divisor = 25.0;
		}
		else // Greater than 300.0
		{
			divisor = 100.0;
		}

		return = Math.Ceiling(x / divisor) * divisor;
	}
};
@dimven

This comment has been minimized.

Copy link
Contributor

dimven commented Nov 30, 2018

The ternary syntax seems to only work in associative mode. Whenever you put it inside of an imperative scope, the VM fails to compile the DS function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment