Drop workarounds for issues that are now fixed - #3
Merged
Conversation
Three of the rough edges these examples were written around have landed, and the comments explaining them are now describing a compiler that no longer exists. http_server read fields with `stringify`, which returns the JSON ENCODING of a value - so the path arrived as `"/echo"` with its quotes and the router had to compare against `"\"/echo\""`. The typed accessors (#392) return the value itself, so `field` uses `as_string` and the router matches `/echo`. `status` is a number in the document, so it reads through `as_int` rather than `as_string`: which accessor to reach for is decided by what the field holds. Each returns an optional, because a field holding a different kind than expected is ordinary when reading a document you did not write. route_finder imported `std.dsa.collection.Collection` only because `Graph` implements it and importing the type without it was an internal compiler error. An import now brings along the interfaces the type implements (#391), so the line goes. The `std.dsa.*` wildcard stays - `algorithm.reverse` comes from it. Expected output changes with the quotes: `server handled GET /echo`.
|
| Filename | Overview |
|---|---|
| AGENTS.md | Replaces obsolete import and multiline-expression guidance with current compiler behavior. |
| examples/http_server/main.mux | Replaces JSON serialization-based field reads with typed string and integer accessors and routes using decoded paths. |
| examples/http_server/README.md | Documents typed JSON field access and removes the obsolete quoted-string workaround. |
| examples/http_server/expected_output.txt | Updates the recorded output to reflect decoded method and path strings. |
| examples/route_finder/main.mux | Removes the redundant Collection import while retaining imports used by the graph, queue, and reverse operation. |
| examples/route_finder/README.md | Removes the stale warning that importing Graph without Collection causes a compiler error. |
Reviews (3): Last reviewed commit: "Merge branch 'main' into chore/drop-fixe..." | Re-trigger Greptile
Removing the Collection import left two files still telling readers it was required: route_finder's README called the four imports load-bearing and named the internal compiler error, and AGENTS.md listed the import as a hard rule. Contradicting the code they document is worse than either state alone. AGENTS.md carried a second stale rule while I was in there - expressions have been able to span an open bracket since #395 - and gained the one that replaced the ICE: a namespace import binds the namespace, so after `import std.net` the type is `net.TcpListener` and the bare name is not in scope. Caught by Greptile on the PR.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three rough edges these examples were written around have landed, so the comments explaining them now describe a compiler that no longer exists.
http_server read fields with
stringify, which returns the JSON encoding of a value - so the path arrived as"/echo"with its quotes and the router compared against"\"/echo\"". The typed accessors (muxlang/mux-compiler#392) return the value itself, sofieldusesas_stringand the router matches/echo.statusis a number in the document, so it reads through a newint_fieldusingas_intrather thanas_string- which accessor to reach for is decided by what the field holds, not by what you want to do with it afterwards. Each returns anoptional, because a field holding a different kind than expected is ordinary when reading a document you did not write.route_finder imported
std.dsa.collection.Collectiononly becauseGraphimplements it and importing the type without it was an internal compiler error. An import now brings along the interfaces the type implements (muxlang/mux-compiler#391), so the line goes. Thestd.dsa.*wildcard stays -algorithm.reversecomes from it.Expected output changes with the quotes:
server handled GET /echo.Corpus passes 12/12 locally against mux-compiler main.