Created
July 24, 2022 17:35
-
-
Save miller-time/93c8c1e407f38cbebc14d1a834ee604f to your computer and use it in GitHub Desktop.
Jakt Builder Pattern
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
class Foo { | |
_bar: i64 | |
_baz: c_char | |
_qaz: String | |
public function bar(mut this, anon bar: i64) -> Foo { | |
this._bar = bar | |
return this | |
} | |
public function baz(mut this, anon baz: c_char) -> Foo { | |
this._baz = baz | |
return this | |
} | |
public function qaz(mut this, anon qaz: String) -> Foo { | |
this._qaz = qaz | |
return this | |
} | |
} |
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
➜ jakt_selfhost -b builder.jakt | |
build/builder.cpp:22:8: error: no viable conversion from returned value of type 'Jakt::Foo *' to function return type 'NonnullRefPtr<Jakt::Foo>' | |
return (this); | |
^~~~~~ | |
runtime/Jakt/NonnullRefPtr.h:53:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::Foo &' for 1st argument; dereference the argument with * | |
ALWAYS_INLINE NonnullRefPtr(T const& object) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:71:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'Jakt::NonnullRefPtr<Jakt::Foo> &&' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr&& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:82:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::NonnullRefPtr<Jakt::Foo> &' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:108:5: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const RefPtr<Jakt::Foo> &' for 1st argument | |
NonnullRefPtr(RefPtr<T> const&) = delete; | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:19: note: candidate template ignored: constraints not satisfied [with U = Jakt::Foo *] | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:59: note: because 'IsConvertible<Jakt::Foo **, Jakt::Foo *>' evaluated to false | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:77:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U>&& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:89:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:105:5: note: candidate template ignored: could not match 'RefPtr<U>' against 'Jakt::Foo *' | |
NonnullRefPtr(RefPtr<U> const&) = delete; | |
^ | |
build/builder.cpp:29:8: error: no viable conversion from returned value of type 'Jakt::Foo *' to function return type 'NonnullRefPtr<Jakt::Foo>' | |
return (this); | |
^~~~~~ | |
runtime/Jakt/NonnullRefPtr.h:53:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::Foo &' for 1st argument; dereference the argument with * | |
ALWAYS_INLINE NonnullRefPtr(T const& object) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:71:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'Jakt::NonnullRefPtr<Jakt::Foo> &&' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr&& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:82:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::NonnullRefPtr<Jakt::Foo> &' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:108:5: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const RefPtr<Jakt::Foo> &' for 1st argument | |
NonnullRefPtr(RefPtr<T> const&) = delete; | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:19: note: candidate template ignored: constraints not satisfied [with U = Jakt::Foo *] | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:59: note: because 'IsConvertible<Jakt::Foo **, Jakt::Foo *>' evaluated to false | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:77:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U>&& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:89:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:105:5: note: candidate template ignored: could not match 'RefPtr<U>' against 'Jakt::Foo *' | |
NonnullRefPtr(RefPtr<U> const&) = delete; | |
^ | |
build/builder.cpp:36:8: error: no viable conversion from returned value of type 'Jakt::Foo *' to function return type 'NonnullRefPtr<Jakt::Foo>' | |
return (this); | |
^~~~~~ | |
runtime/Jakt/NonnullRefPtr.h:53:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::Foo &' for 1st argument; dereference the argument with * | |
ALWAYS_INLINE NonnullRefPtr(T const& object) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:71:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'Jakt::NonnullRefPtr<Jakt::Foo> &&' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr&& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:82:19: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const Jakt::NonnullRefPtr<Jakt::Foo> &' for 1st argument | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr const& other) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:108:5: note: candidate constructor not viable: no known conversion from 'Jakt::Foo *' to 'const RefPtr<Jakt::Foo> &' for 1st argument | |
NonnullRefPtr(RefPtr<T> const&) = delete; | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:19: note: candidate template ignored: constraints not satisfied [with U = Jakt::Foo *] | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:60:59: note: because 'IsConvertible<Jakt::Foo **, Jakt::Foo *>' evaluated to false | |
ALWAYS_INLINE NonnullRefPtr(U const& object) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:77:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U>&& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:89:19: note: candidate template ignored: could not match 'NonnullRefPtr<U>' against 'Jakt::Foo *' | |
ALWAYS_INLINE NonnullRefPtr(NonnullRefPtr<U> const& other) requires(IsConvertible<U*, T*>) | |
^ | |
runtime/Jakt/NonnullRefPtr.h:105:5: note: candidate template ignored: could not match 'RefPtr<U>' against 'Jakt::Foo *' | |
NonnullRefPtr(RefPtr<U> const&) = delete; | |
^ | |
3 errors generated. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment