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

switch with a single case does not parse #868

Open
SimonCockx opened this issue Nov 12, 2024 · 3 comments
Open

switch with a single case does not parse #868

SimonCockx opened this issue Nov 12, 2024 · 3 comments
Labels
bug Something isn't working subject: model validation This issue is about validation of Rosetta models, such as the type system subject: syntax This issue is about the syntax of Rosetta

Comments

@SimonCockx
Copy link
Contributor

The switch syntax should be less restrictive, otherwise users get confusing error messages. For example, the following will raise an error on switch "Expected EOF":

criterium switch
            AssetType then empty

The same for a switch without any cases. The parser should allow it, although validation should fail.

@SimonCockx SimonCockx added bug Something isn't working subject: syntax This issue is about the syntax of Rosetta subject: model validation This issue is about validation of Rosetta models, such as the type system labels Nov 12, 2024
@SimonCockx
Copy link
Contributor Author

Similarly, this switch without a default causes a similar error:

criterium switch
            AssetType then empty,
            AgencyRatingCriterium then empty,
            AllAssetCriteria then empty,
            AnyAssetCriteria then empty,
            NegativeAssetCriterium then empty

Adding default empty solves it.

@SimonCockx
Copy link
Contributor Author

Also, when the branches do not match type, error propagation is not correct. I.e., the enclosing expression gets an error

Expected type 'XXX' but was 'any'

@SimonCockx
Copy link
Contributor Author

Correction: a single case works, but somehow not if directly followed by another function definition.

func Foo:
	inputs:
		criterium AssetCriterium (1..1)
	output:
		result boolean (1..1)
	set result:
		criterium switch
			AssetType then empty

func OtherFunc:
	inputs:
		inp int (1..1)
	output:
		outp int (1..1)

If OtherFunc is not there, it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working subject: model validation This issue is about validation of Rosetta models, such as the type system subject: syntax This issue is about the syntax of Rosetta
Projects
None yet
Development

No branches or pull requests

1 participant