Skip to content

Conversation

@JeroenUH
Copy link
Contributor

There was a bug with the Haskell judge where the list that contains the command line arguments was not correctly compiled into Haskell, due to a missing comma in the generated output.

Example Testcase

- tab: "command_line_arguments"
  testcases:
  - arguments: ["banana", "apple", "apple", "orange", "apple", "apple", "banana", "orange"]
    stdout: "apple banana orange"

The following line is responsible for converting it to Haskell:

result += indent + f"let mainArgs = [{' '.join(wrapped)}]\n"

However, this generates something like this:

let mainArgs = ["banana" "apple" "apple" "orange" "apple" "apple" "banana" "orange"]

This causes an error like this:

Execution0.hs:64:21: error: [GHC-83865]
    • Couldn't match expected type: String
                                    -> String -> String -> String -> String -> String -> String -> a
                  with actual type: [Char]
    • The function ‘"banana"’ is applied to 7 value arguments,
        but its type ‘[Char]’ has none
      In the expression:
        "banana" "apple" "apple" "orange" "apple" "apple" "banana" "orange"
      In the expression:
        ["banana"
           "apple" "apple" "orange" "apple" "apple" "banana" "orange"]

In Haskell, arrays are comma separated. This PR adds the commas, as well as a test-case for it.

@JeroenUH JeroenUH changed the title Correctl generate multiple CLI arguments for Haskell Correctly generate multiple CLI arguments for Haskell Feb 21, 2025
@bmesuere bmesuere requested a review from niknetniko February 21, 2025 14:34
@niknetniko niknetniko added bug Something isn't working run tests Only add after checking code for security risks labels Feb 21, 2025
Copy link
Member

@niknetniko niknetniko left a comment

Choose a reason for hiding this comment

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

You'll need to run the formatter, but otherwise changes look good to me.

@niknetniko niknetniko added run tests Only add after checking code for security risks and removed run tests Only add after checking code for security risks labels Feb 24, 2025
@niknetniko niknetniko self-requested a review February 24, 2025 15:17
@jorg-vr jorg-vr merged commit 2e7d7b3 into dodona-edu:master Feb 26, 2025
10 checks passed
@jorg-vr
Copy link
Contributor

jorg-vr commented Feb 26, 2025

Thanks for your contribution!

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

Labels

bug Something isn't working run tests Only add after checking code for security risks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants