Skip to content

Pass connected funtest on all but js and interp - #465

Merged
tjpalmer merged 8 commits into
mainfrom
more-connected
Jul 30, 2026
Merged

Pass connected funtest on all but js and interp#465
tjpalmer merged 8 commits into
mainfrom
more-connected

Conversation

@tjpalmer

@tjpalmer tjpalmer commented Jul 21, 2026

Copy link
Copy Markdown
Contributor
  • Pass connected functions funtest on all backends except interp and js
  • Also refine be-py connecteds some
  • To some extent, this is drafting the plan for userspace connecteds, maybe good approximately as is, but some forms of adjustment wouldn't be too hard
  • Js is hard because standard import is only top level and our "whatever.internal.js" handling is still awkward
  • Interp needs some way for backends to know when to use temper impl vs connected code

tjpalmer added 7 commits July 15, 2026 05:34
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
Signed-off-by: Tom <tom@temper.systems>
@tjpalmer tjpalmer changed the title Pass connected funtest on all but js Pass connected funtest on all but js and interp Jul 21, 2026
// For more on includes, see https://en.cppreference.com/cpp/preprocessor/include#Notes
Include ::= "#" & "include" & "<" & path%Raw & ">" & "\n";
/** For string literals, although escapes don't work. */
IncludeLocal ::= "#" & "include" & path%LiteralExpr & "\n";

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Technically not necessarily local-priority includes, but typically all compilers treat them that way, and it at least provides a different convention that can be used by compilers.

Separately, I tried explicit double-quotes around raw to make differences from strings more explicit, but the spacing was off, and it doesn't really accomplish anything.

content = file.value,
).also { add(it) }
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

For all the backends, I haven't tested submodules yet. Putting that off for build tests in a future PR.

fileExtensionMap = mapOf(
FileType.Module to lang.ext,
FileType.Script to lang.ext,
FileType.Header to HPP_EXT,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We need extensions registered for all files we might want to copy.

mimeTypeMap = mapOf(
FileType.Module to MimeType.cppSource,
FileType.Script to MimeType.cppSource,
FileType.Header to MimeType.cppSource,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We were already supplying this mime type for header files, just not using this map.

def == WellKnownTypes.dequeTypeDefinition ->
WellKnownTypes.dequeTypeDefinition ->
return sharedPtr(cpp.template(cppBaseTypeForDefinition(def)!!, typeArgs))
else -> {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The overall change recommended by ij, and it's cleaner overall except for needing the else. Went along with it.

return i * j
end

return exports

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made "support" or "more" code for each backend just to prove we have access to them. And made class-like things in each also just for kicks.

@@ -0,0 +1,15 @@
namespace Work
{
static class WorkConnected

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We already had <Lib/Mod>Global in be-csharp and be-java, so I reused the same style for <Lib/Mod>Connected for both. But after everyone else is just getting _connected, it's almost tempting to do that for csharp and java also. Or maybe I should make others more idiomatic instead of making these worse. Don't know. These can be refined in future PRs, if we decide for sure to change from what I've made so far.

internal static int Prod(Hidden hidden, int j)
{
return new MoreSupport().Prod(hidden.I, j);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am trying to make the functions themselves use idiomatic naming. And I've proved I can use the Hidden type in each backend.

return i + j + bonus
end

---@param hidden work.Hidden TODO Actually define types in our Lua.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We don't yet generated static EmmyLua (or rather Lua Language Server) typing in our LuaTranslator, and we also don't strip numeric suffices yet. But we also don't need static typing for Lua to work. I just wanted to do static type annotations where possible in the lua connected code in this PR, anyway. This is just the case I can't do yet.

Shaw also would like to make generating type annotations optional in the future, if we do get around to generating them (which I personally would greatly like, as luals is actually pretty high quality in my using it so far in hobby things).

Script,

/** a header file for pre-declarations */
Header,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Felt a bit bad adding this, but C and/or OCaml and/or others might also want header files in the future.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this just keys into a lookup table for mime types so helps in picking accurate mime-types?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So this just keys into a lookup table for mime types so helps in picking accurate mime-types?

I don't think all backends even use them meaningfully. Looks like FileType.Module gets used in a couple of places. I'm not sure others do at all. But fileExtensionMap and mimeTypeMap in BackendMeta need them. We maybe could adjust in the future. But I needed something other than Module to list .hpp, and JsModule and Script both seemed very wrong.

Signed-off-by: Tom <tom@temper.systems>
@tjpalmer
tjpalmer marked this pull request as ready for review July 21, 2026 22:14

@mikesamuel mikesamuel left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What would it take to have our backend test framework test how backends and translators deal with connected files?

PreProc = Define | Undef | Pragma | IncludeGuard | Include | IfPreProc;
PreProc = Define | Undef | Pragma | IncludeGuard | Include | IncludeLocal | IfPreProc;
// For more on includes, see https://en.cppreference.com/cpp/preprocessor/include#Notes
Include ::= "#" & "include" & "<" & path%Raw & ">" & "\n";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you run into formatting glitches you could try token references for some of these with specified operator association. Like < as bracket operators instead of as infix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note to self: these resources are just for the connected functional test.

Script,

/** a header file for pre-declarations */
Header,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this just keys into a lookup table for mime types so helps in picking accurate mime-types?

Comment thread functional-test-matrix.md
| [ControlFlowLoops][] | ✅ | ❌<sup>[198][]</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [FunctionsAsValues][] | ✅ | ❌<sup>[198][]</sup> | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| [FunctionsConnected][] | ❌<sup>[456][]</sup> | ❌<sup>[198][]</sup> | ❌<sup>[456][]</sup> | ❌<sup>[456][]</sup> | ✅ | ✅ | ❌<sup>[456][]</sup> | ❌<sup>[456][]</sup> | ✅ | ✅ | ❌<sup>[456][]</sup> |
| [FunctionsConnected][] | | ❌<sup>[198][]</sup> | | ❌<sup>[456][]</sup> | ✅ | ✅ | ❌<sup>[456][]</sup> | | ✅ | ✅ | |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎉

@tjpalmer

Copy link
Copy Markdown
Contributor Author

What would it take to have our backend test framework test how backends and translators deal with connected files?

Do you mean just the ...BackendTest suites? If so, it would be fairly easy to include them. I didn't feel like I would get much out of them, but it sounds like you would, so I can add some in future PRs, at least.

@tjpalmer
tjpalmer merged commit 88f4798 into main Jul 30, 2026
2 checks passed
@tjpalmer
tjpalmer deleted the more-connected branch July 30, 2026 14:55
@tjpalmer tjpalmer mentioned this pull request Jul 31, 2026
7 tasks
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