Skip to content

Conversation

ironm00n
Copy link
Contributor

This is only an issue when a program has srclocs from multiple files, but we run into this in the autograder.

Copy link
Member

@blerner blerner left a comment

Choose a reason for hiding this comment

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

This is weird, but I think I get it. I think you have it subtly wrong, though:

student-code1 inserted-code1 student-code2

will cause no distinct-line errors to be emitted. I think you might want to remove this change here, and instead call ensure-distinct-lines on a filtered list of statements, where you remove any instructor-inserted code. Does that meet your needs, or am I misunderstanding the problem?

cases(Loc) loc:
| builtin(_) => ensure-distinct-lines(first.l, A.is-s-template(first), rest)
| srcloc(_, _, _, _, end-line1, _, _) =>
| srcloc(end-source1, _, _, _, end-line1, _, _) =>
Copy link
Member

Choose a reason for hiding this comment

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

This should just be named source1 -- the fields being extracted here are named end-line and start-line, and the suppliers are numbered 1 and 2. So if you're extracting a new field, just name it source

@ironm00n
Copy link
Contributor Author

ironm00n commented Oct 15, 2025

will cause no distinct-line errors to be emitted.

For our use-case that is fine, since we already rely on a student's file being well-formed before performing any AST manipulations.

Our motivation being that if a program has content from multiple different sources, the srcloc information is far less meaningful here.

instead call ensure-distinct-lines on a filtered list of statements

I'm not sure what this would entail, currently we run the merged code through the entire compiler pipeline, the amount of work to book keep for what segments of the code correspond to who originally wrote it, and then selectively running different compiler passes doesn't seem like a good use of anyone's resources.


Perhaps our needs are more along the lines of being able to be more selective about well-formedness checks are run on our resulting code?

We just implemented this fix since a few students had hit edge cases where the line numbers of our files and theirs would collide and cause the autograder's REPL to reject their program.

@blerner
Copy link
Member

blerner commented Oct 15, 2025

I was just suggesting that at the call site for ensure-distinct-lines, you filter the stmts list to only contain statements whose source doc equals the doc of the s-program root -- that would filter out your inserted statements, and then the well-formedness check itself would stay unchanged.

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.

3 participants