Skip to content

Conversation

@ohhmm
Copy link
Owner

@ohhmm ohhmm commented Mar 9, 2025

Fix compilation for visual studio clang distribution

Valuable::universal_lambda_t CompileIntoLambda(Valuable::variables_for_lambda_t) const override {
return [](Valuable::universal_lambda_params_t) -> Valuable {
return GlobalObject;
return NewDefaultValuable();
Copy link
Contributor

Choose a reason for hiding this comment

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

The PR introduces a template-related issue in Constant.h that's causing build failures. The error is: "there are no arguments to 'NewDefaultValuable' that depend on a template parameter, so a declaration of 'NewDefaultValuable' must be available [-fpermissive]"

The problem is that NewDefaultValuable() is being called in Constant.h before it's declared in the template context. To fix this, you need to either:

  1. Forward-declare the NewDefaultValuable() method before using it in CompileIntoLambda()
  2. Or move the implementation of NewDefaultValuable() in ValuableDescendantContract.h before the CompileIntoLambda() method in Constant.h

This is causing build failures on both Ubuntu and Windows CI environments.

Valuable Euler::Sq() const {
auto exponentiation = ptrs::make_shared<Exponentiation>(*this, 2);
return Valuable(exponentiation);
return Valuable(std::move(exponentiation));
Copy link
Contributor

Choose a reason for hiding this comment

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

The std::move() addition in Euler.cpp is a good optimization for avoiding unnecessary copies of shared pointers. However, for consistency, you might want to apply similar optimizations in other similar code patterns throughout the codebase. This would help with both performance and ensuring consistent coding style across the project.

Comment on lines +149 to +155

static constexpr Valuable NewDefaultValuable() {
auto obj = ptrs::make_shared<Chld>();
return Valuable(std::static_pointer_cast<Valuable>(obj));
Copy link
Contributor

Choose a reason for hiding this comment

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

The new NewDefaultValuable() method in ValuableDescendantContract.h is a good addition for creating default valuable objects, but it's causing template resolution issues when used in Constant.h. Consider adding a forward declaration or rearranging the code to ensure the method is visible before it's used.

Also, since this is a static method that creates a new object, consider adding a brief comment explaining its purpose and when it should be used versus the existing GlobalObject pattern.

@ohhmm ohhmm force-pushed the vs-clang-fix branch 3 times, most recently from f5f0854 to 8198844 Compare March 21, 2025 20:58
@ohhmm ohhmm force-pushed the vs-clang-fix branch 2 times, most recently from 8c775c1 to 22d469d Compare March 28, 2025 08:18
return exp;
}

static constexpr Valuable NewDefaultValuable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The NewDefaultValuable() method in ValuableDescendantContract.h is defined after it's used in Constant.h, which could cause template resolution issues with some compilers (particularly Visual Studio's Clang distribution).

Recommendation: Consider moving the NewDefaultValuable() method definition earlier in the ValuableDescendantContract class, before it's used in CompileIntoLambda(), or add a forward declaration at the beginning of the class.

Valuable Euler::Sq() const {
auto exponentiation = ptrs::make_shared<Exponentiation>(*this, 2);
return Valuable(exponentiation);
return Valuable(std::move(exponentiation));
Copy link
Contributor

Choose a reason for hiding this comment

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

The std::move() optimization in Euler.cpp is a good improvement for avoiding unnecessary copies of shared pointers. For consistency, consider applying similar optimizations in other similar code patterns throughout the codebase, such as in other classes that return Valuable objects with shared pointers.

return exp;
}

static constexpr Valuable NewDefaultValuable() {
Copy link
Contributor

Choose a reason for hiding this comment

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

The new NewDefaultValuable() method in ValuableDescendantContract.h lacks documentation explaining its purpose and when it should be used versus the existing GlobalObject pattern. Consider adding a brief comment to clarify its intended usage and relationship to other object creation methods in the codebase.

@ohhmm ohhmm force-pushed the vs-clang-fix branch 3 times, most recently from f317aa1 to f0d5393 Compare March 30, 2025 18:16
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