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

Optional Arguments #220

Closed
wants to merge 0 commits into from
Closed

Conversation

noordahx
Copy link

Draft PR:

  • Resolved merge conflicts of original PR
  • Tests failed at OptionalArgs.mls
fun f1(a: Int, b: Int) = a + b
//│ ╔══[ERROR] Type mismatch in operator application:
//│ ║  l.17: 	fun f1(a: Int, b: Int) = a + b
//│ ║        	                         ^^^^^
//│ ╟── type `()` is not an instance of type `Int`
//│ ║  l.17: 	fun f1(a: Int, b: Int) = a + b
//│ ║        	          ^^^
//│ ╟── but it flows into reference with expected type `Int`
//│ ║  l.17: 	fun f1(a: Int, b: Int) = a + b
//│ ╙──      	                         ^
//│ TEST CASE FAILURE: There was an unexpected type error
//│ fun f1: (a: Int | (), b: Int | ()) -> (Int | error)

@LPTK
Copy link
Contributor

LPTK commented May 24, 2024

Hi @noordahx, thanks for the PR draft. Do you need some assistance in moving it forward?

Comment on lines 18 to 26
//│ ╔══[ERROR] Type mismatch in operator application:
//│ ║ l.17: fun f1(a: Int, b: Int) = a + b
//│ ║ ^^^^^
//│ ╟── type `()` is not an instance of type `Int`
//│ ║ l.17: fun f1(a: Int, b: Int) = a + b
//│ ║ ^^^
//│ ╟── but it flows into reference with expected type `Int`
//│ ║ l.17: fun f1(a: Int, b: Int) = a + b
//│ ╙── ^
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @LPTK , I am having trouble with function parameter type parsing (seems all of the parameter types are '()' by default)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NewParser.scala "?" parser -> line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That code does not make much sense to me. You may have mismerged the conflicts. The code is computing (argName, argOpt) by consuming an identifier, ?, and : tokens. And then it redundantly checks optionality with isOptional – the logic is all messed up. I'm guessing the () might come from consuming the type tokens and then parsing an empty expression (which produces undefined, aka ()), or it could be the later logic to make things optional that's broken. It might be better to start the parsing change from scratch.

@noordahx noordahx closed this Jun 25, 2024
@noordahx noordahx force-pushed the optional-arguments branch from 7648ae3 to 13ba521 Compare June 25, 2024 06:00
@noordahx noordahx deleted the optional-arguments branch June 25, 2024 06:00
@noordahx noordahx restored the optional-arguments branch June 25, 2024 06:33
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

Successfully merging this pull request may close these issues.

2 participants