Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error: could not convert..." after 3.2.1 -> 3.4.2 upgrade #6121

Closed
IBwWG opened this issue Mar 21, 2017 · 5 comments
Closed

"error: could not convert..." after 3.2.1 -> 3.4.2 upgrade #6121

IBwWG opened this issue Mar 21, 2017 · 5 comments
Assignees
Labels
platform-cpp Everything related to CPP / C++

Comments

@IBwWG
Copy link
Contributor

IBwWG commented Mar 21, 2017

The following code compiled fine (transpiled to cpp via openfl build linux, hxcpp 3.4.49) on my 64-bit Linux Mint box, with Haxe 3.2.1 and Neko 2.1.0:

add(new Speech(BalloonStyle.TALK, mathilda, 1019, 107, 213, ["Yay!  Look at all the fairy dust they gave me!", "Youpeeee!"], 3, function () {
 	add(new Speech(BalloonStyle.TALK, mathilda, 1019, 107, 213, ["This is so fun!\nC'mon, Willy...\ncatch up!"], 3,
		timer.start.bind(3, postMiniGame)
	));
	Main.fadeOutMusic(null, 3);
}));

After the upgrade, without any changes, I attempted a recompile, and got this error:

Error: ./src/minigames/CollectFairyDustState.cpp: In member function ‘flixel::util::FlxTimer minigames::CollectFairyDustState_obj::set_points(int)::_hx_Closure_1::_hx_run()::_hx_Closure_0::_hx_run()’:
./src/minigames/CollectFairyDustState.cpp:626:53: error: could not convert ‘Dynamic::operator()(const Dynamic&, const Dynamic&, const Dynamic&)(Dynamic(3), ((minigames::CollectFairyDustState_obj::set_points(int)::_hx_Closure_1::_hx_run()::_hx_Closure_0*)this)->minigames::CollectFairyDustState_obj::set_points(int)::_hx_Closure_1::_hx_run()::_hx_Closure_0::a2, Dynamic(null())).Dynamic::operator int()’ from ‘int’ to ‘flixel::util::FlxTimer {aka hx::ObjectPtr<flixel::util::FlxTimer_obj>}’
 HXLINE( 175)      return ( (int)(f((int)3,a2,null())) );
                                                     ^

If I changed the inner add() call to use a function wrapper rather than .bind(), it compiles on 3.4.2:

	add(new Speech(BalloonStyle.TALK, mathilda, 1019, 107, 213, ["This is so fun!\nC'mon, Willy...\ncatch up!"], 3,
		function () {timer.start(3, postMiniGame);}
	));

I found it interesting that just this one spot in the entire project was all that broke, considering I use .bind a total of 42 times throughout it, including in an extremely similar context:

add(new Speech(BalloonStyle.TALK, mathilda, 975, 580, 184, ["I found the Lost Piece!"], 3, function(){
	add(new Speech(BalloonStyle.TALK, willy, 872, 518, 293, ["So that's what Atlantis looks like!"], 3,
		timer.start.bind(3, postMiniGame)
	));
}));

I'm failing to see the difference between that code, which works without modification on both 3.2.1 and 3.4.2, and the code at the top, which needed to be changed for 3.4.2. But I thought I should at least post my findings and the workaround that worked for me.

@IBwWG
Copy link
Contributor Author

IBwWG commented Mar 21, 2017

Updating to hxcpp 3.4.64 changes the build order somehow so that the error occurs much later in the build process, but the same error still occurs; the same workaround still makes it work.

@nadako nadako added the platform-cpp Everything related to CPP / C++ label Mar 21, 2017
@hughsando
Copy link
Member

This looks like the typing of the TReturn field that I changed.
In which case, the difference is probably due to the return type of the enclosing function rather than any differences between the lines of code themselves.
If you could post a small example, that would be great.
If not, the function declaration (args and return type_ of timer.start and add and the function that works and the function that does not would really help.

@IBwWG
Copy link
Contributor Author

IBwWG commented Mar 22, 2017

Sorry for the delay. I'm confused--the lines of codes refer to the same function, so it naturally has the same return type...where would the difference be? Anyway given that you've closed it, do you still want the function declaration or is it moot at this point?

@hughsando
Copy link
Member

No thanks - I managed to work something out.
The difference is in the enclosing function (surrounding what you have shown here). If the closure is inside a function that returns an int, you get this issue.

@IBwWG
Copy link
Contributor Author

IBwWG commented Mar 22, 2017

Super, and thanks for satisfying my curiosity. Glad you were able to figure it out so fast!

markknol added a commit to markknol/haxe that referenced this issue Mar 28, 2017
* [php7] correctly detect write context to optimize more cases of array access

* and again

* [php7] Remove filehandle import in resource (HaxeFoundation#5989)

`sys.io.File has no field or subtype FileHandle`

* Fix some spelling errors in docs (HaxeFoundation#5991)

* [php7] print haxe positions above each line of generated php code

* [php7] do not print Haxe positions if -D real-position is defined

* [lua] add arguments and docs to the Math.random* functions

* [php7] dereference only if really needed

* Do not rewrite path for abstracts when applying @:native (closes HaxeFoundation#5993)

We don't need to do this, because it's already done for their implementation class as a result of forwarding @:native to them on creation,
and only classes can be restored, not abstracts, as far as I understood.

* mention HaxeFoundation#5993 in CHANGES

* [display] don't complain about body-less functions in completion (closes HaxeFoundation#5988)

* [php7] php.NativeStructArray for associatie arrays used as a set of options

* [lua] fix and beautify lua.Math extern

(docs taken from https://www.lua.org/manual/5.1/manual.html#5.6)

* [lua] fix issues with typedef/instance/static assignment fixes HaxeFoundation#6007

* fix Issue6007 for other platforms

* fix Issue6007 for flash

* [lua] disable fusion on Table.create

* [lua] add test for issue6001

* fix Issue6001

* reverse the reversal (closes HaxeFoundation#6015)

* [cpp] StringBuf - only flush the charBuf once.  Fixes HaxeFoundation#6018

* [cpp] Use @:native gc functions instead of __global__.  Fixes HaxeFoundation#6014

* Fixed missing separator after __properties__ (HaxeFoundation#6024)

* [js] don't inline Reflect.(get|set)Property methods, as those are too big and messy for that

* [cpp] Mark Gc functions as extern.

* [AppVeyor] fix php installation

* [cpp] Allow host ip of 0, if name is '0.0.0.0' closes HaxeFoundation#5987

* [cpp] Make Gc extens cppia friendly

* update haxelib (HaxeFoundation#6032)

* [php] fixed invalid result of Web.getPostData() (fixes HaxeFoundation#6073)

* typo

* [lua] fix HaxeFoundation#6037

* [lua] focus type parameter for lua/coroutine

* [php7] Actually withdraw fetched row (HaxeFoundation#6041)

* [php7] Actually withdraw fetched row

* [php7] a test for HaxeFoundation#6041

* fix random syntax

* fix some names in unitstd

and hope that these aren't broken

* Revert "fix some names in unitstd"

This reverts commit 466aa3c.

* [lua] avoid allocation with type.getEnumParameters

* [php7] throw EOF if reading from BytesBuffer reached the end (fixes HaxeFoundation#6043)

* [php7] Save stack of a caught exception only if CallStack.exceptionStack() is used somewhere (fixes HaxeFoundation#6046)

* [php7] dont print positions for blocks in generated code

* [lua] handle luaRequire import declarations in the type_forward generator

* [lua] use local inline function for Type.getEnumParameters

* [lua] use unsafe cast in Type.enumParameters

* [lua] do some bounds checking for Std.int, and return 0 if infinite/nan

* [lua] double-escape lua Ereg group match capture tokens

* support toString on Any, so it behaves similar to Dynamic when used in string concatenation/interpolation

* [analyzer] do not bind `@:structAccess` to temp vars

* bugfix OpAssignOp on some arrays

* fix correct file close

* make generated `return` position match the position of an expr being returned from a complex expr

this should help js source maps and other debugging

* Sourcemap support for php7 (HaxeFoundation#6052)

* sourcemap generator draft

* trying to update Makefile for sourcemaps

* fix sourcemap_file#new_line

* added sourcemap generator to genphp7 as proof-of-concept

* sourcemap_builder draft

* [php7] refactor write_args

* [php7] use parent_expr instead of expr_hierarchy for cleaner code

* [php7] all output through type_builder#write

* fix line numbers in sourcemap

* fix accumulating sourcemaps of all previousely generated files

* fix line mapping if stack trace does not provide coumn information

* [php7] correctly build sourcemap for closures

* fix typo

* source_map define

* [php7] haxe.CallStack.mapPosition for pretty call stacks

* [lua] fix Ffi typing problems

* [php7] use strlen for strings in FileInput.readBytes (HaxeFoundation#6055)

* use strlen for strings in FileInput.readBytes

* fixed unitest to close test file

* [php7] remove redundant case in field access generation

* call db.close instead of this.close to avoid recursion (HaxeFoundation#6056)

* changelog

* [php] test for HaxeFoundation#6057

* [php7] fix String.indexOf() default values for `startIndex` argument

* Fix for HaxeFoundation#6057 FileSystem.stat() fails on directories (HaxeFoundation#6058)

Looks like it's a windows-only issue. Thanks for the fix.

* changelog

* remove wild spaces

* write errors to stdout instead of stderr because our output goes to stderr instead of stdout

Don't ask me

* use --php-front parameter (HaxeFoundation#6060)

* [php] setup appveyor

* fix HaxeFoundation#6067

* added gc flags and tracking api

* update hl.Gc.track

* added obj as callb param

* add test for HaxeFoundation#6067, mention the fix in changelog

* [php7] maintain statics initialization order (fixes HaxeFoundation#6070)

* [display] check whether the type we want to get signature for is actually callable (closes HaxeFoundation#6068)

* [display] store signatures directly in DisplaySignatures, instead of TFun - less run-time checks, more type safety \o/

* Do not generate scriptable glue for callable variables. Closes HaxeFoundation/hxcpp#573

* bump version

* [cpp] Fix is_data_member call

* silently create unbound var infos instead of asserting

* [cpp] Return CallableData instead of T for 'call' member

* do not lose field type when calling a var/property function

* minor

* [php7] generator refactoring

* [php7] support haxe.EntryPoint

* add a function to print out current unification stacks

* [cpp] Make cpp.Funciton.call return FunctionData

* fix structural extension display position

closes HaxeFoundation#6029
closes HaxeFoundation#6077

* [php7] dreference field access on `null`; more cases for HaxeFoundation#4988

* [php] fix null.nonExistent()

* disable test for `null.nonExistent()` on lua and as3

* disable test for `null.nonExistent()` on lua and as3

* only account actual typing for the "macro typing" timer

* Update Array.hx (HaxeFoundation#6084)

minor addition to clarify result is return value

* [php] changed _hx_cast() to use _hx_instancof() instead of Std.is() to avoid handling php-prefix (fixes HaxeFoundation#6083)

* [lua] put static initialization in helper method and delay evaluation.  fix HaxeFoundation#6087

* update submodule

* CHANGES.txt update

* [lua] fix missing type handler

* [cpp] Allow raw native pointers (cpp.Star) and structs in hxcpp, and explicitly add the dynamic conversions where required

* added sentinel pause

* [cpp] Add line number entry at start of functions to allow breaking on entering.

* [lua] use custom Eof with local dce disabled

* [lua] better error messages for missing/incorrect file input

* Revert "[lua] use custom Eof with local dce disabled"

This reverts commit bd526d5.

* [lua] avoid duplicate init calls, the check features routine is no longer necessary

* update release procedure
[skip ci]

* [lua] Lua.setmetatable returns a table

* [lua] drop unnecessary Map class, add some helpers to PairTools

* [lua] nah, pairtool methods probably belong in a 3rd party lib

* UNC paths are absolute paths as well (HaxeFoundation#6061)

* Fix fail to inline extern constructor not producing an error HaxeFoundation#6034 (HaxeFoundation#6035)

* Fix inline extern constructors failing to inline not producing an error HaxeFoundation#6034

* inline constructors bugix optimization:
Keep count of extern inline constructors and only do the third pass if the count is not 0.

* No third pass is needed, check in the second pass if there are extern inline constructors left.

* Manually fix broken API docs of HTMLDocument http://api.haxe.org/js/html/HTMLDocument.html (HaxeFoundation#5936)

I provided a fix for future here HaxeFoundation/html-externs#7

* java.Lib: remove confusing deprecated docs (HaxeFoundation#6026)

Recursion. See also: recursion.

* Fix inline constructor field initialization for super constructors. HaxeFoundation#6093 (HaxeFoundation#6097)

* Handle inline constructor field initialization for super constructors too. Fixes HaxeFoundation#6093

* Reuse cl_params map.

* Add Issue6093 unit test.

* Add Issue6093 optimization test.

* Fix EnumFlags.unset() (HaxeFoundation#6019)

* CHANGES.txt update [skip ci]

* fix date

* Date - Minor API documentation copy fix

Remove "the".

* it's 2017

* Fix typo in FileSystem.isDirectory() docs (HaxeFoundation#6104)

* [tests] don't assume test methods with optional args will work when called throught Reflect.callMethod with no arguments - we don't specify that.

* [cpp] Do not qualify @:native types with global namespace.  Closes HaxeFoundation#6086

* OCD [skip ci]

* remove unused version_is_stable value [skip ci]

* [cpp] Store the expected return type for a function. Closes HaxeFoundation#6103

* [php7] wrap empty array declaration in parentheses if used directly with array access (fixes HaxeFoundation#6090)

* [cpp] Don't emit a line change on the first line of a function

* Improved doc wording for Sys.environment() (HaxeFoundation#6109)

* prepare 3.4.2

* label loops with breaks within switch with a number (algorhithm from gencommon)

* [js] generate labels for loops with breaks within switch (closes HaxeFoundation#3883)

* [js] don't generate unneeded switch breaks

* mention HaxeFoundation#4964 in CHANGES.txt [skip ci]

* only keep haxe.io.Eof.toString if Eof was actually used

* spaces->tabs

* `callback` is long gone

* get rid of silly argument name shortening in .bind()

* [display] show fn.bind as a method in field completion (closes HaxeFoundation#6004)

* added Lib.print and Lib.println (fixed HaxeFoundation#5593) (HaxeFoundation#5594)

* added Lib.print and Lib.println (fixed HaxeFoundation#5593)

* inline function and replace untyped

* remove untyped java

* update getLocalStorage/getSessionStorage check (HaxeFoundation#6079)

Closes HaxeFoundation#6050

If you are browsing private on iOS, localstorage is available but you cannot write in it. It'll throw "QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota."

This can be solved in the detection of localstorage by trying to write something in storage

* [cs/java] adjust tests after 9203fbb

* [cs] don't generate `string.Equals`  for string equality checks - a == b looks better and behaves exactly the same

* remove obsolete comment [skip ci]

* remove some dead code [skip ci]

* [cs/java] remove IteratorsInterfaceExprf, because `TFor`s are always rewritten to while in the analyzer

* [gencommon] remove old comments [skip ci]

* [gencommon] remove commented out IteratorsInterface. tried it - doesn't really work well with other filters. better look into possibility to generate anon structure interfaces in general

* get rid of SPOD dependency for HaxeFoundation#5757 test

* [lua] streamline Std.string(Std.string(...)) declarations to Std.string(...)

* [lua] avoid using dynamic/untyped for table creation

* [lua] OCD indent/spacing tweaks

* remove SPOD (HaxeFoundation#6115)

* remove SPOD

* mention SPOD removal in CHANGES.txt [skip ci]

* [js] remove deprecated JQuery and SWFObject externs (HaxeFoundation#6116)

* try installing curl from chocolatey

* update haxelib [skip ci]

* [cs] rework enum-to-class generation (HaxeFoundation#6119)

* [cs] rework enum-to-class generation

* fix generated enum classes priority

* add latest stuff to CHANGES.txt

* [cpp] Fix return typing for embedded closures. Closes HaxeFoundation#6121

* move toplevel files to src/compiler

Also make Globals not depend on Version

* rename parser.ml to parser.mly

Technically it's not a mly file, but tool automation is annoying if there's a single file that requires the camlp4 preprocessor.

* add Makefile/sh based "build system"

* Some travis cleanup (HaxeFoundation#6110)

* [travis] use neko PPA instead of building it

* install OCaml through opam

* run Php7 tests as part of linux tests

* actually run php7 tests

* quotes?

* disable sauce connect until we figure out how to avoid forks breaking

* split gencommon, moving its actual filters into separate modules (HaxeFoundation#6122)

* fix a type inference warning

* adjust .merlin and finally fix that genlua warning

* move .NET type loading into a separate module, so we don't depend on Gencs for that

* Dotnet module actually belongs to typing, not generation

* move Java type loading into a separate module, so we don't depend on genjava->gencommon for everything

* move SWF type loading into a separate module so we don't depend on SWF generator for that

* spaces -> tabs [skip ci]

* random gencommon cleanup

* random gencommon cleanup 2

* [gencommon] make mk_temp and mk_internal_name simple functions, not tied to gencommon context

* [gencommon] remove unused events

* [gencommon] fix double return in reflection helper exprs (also make mk_return type the TReturn as t_dynamic, like we do in other places)

* [gencommon] move mk_return to Codegen and use it instead of manually constructing TReturn Some

* [gencommon] remove some code duplication

* [gencommon] get rid of Gencommon dependency for SetHXGen filter

* simplify rule_map_dispatcher#add - make its arguments non-optional

* simplify rule_dispatcher a bit

* minor

* move gencs/genjava's configure function inside generate, because it actually generates stuff, not merely configures

* [gencommon] extract RenameTypeParameters into a separate module (also get rid of gencommon context dependency, as it only needs types)

* [gencommon] split up TypeParams module

it really is just the "RealTypeParams" filter and the infer_params function that are used by other methods and don't even need gencommon,
so move infer_params into gencommon (for now), and move the rest into RealTypeParams module

* fix with latest hl.h

* [gencommon] move infer_params into CastDetect.handle_type_parameter as it's the only place where it's used

* [gencommon] cleanup ClassInstance a bit (also cache the __typeof__ var instead of re-creating it for each access)

* sync with extlib changes

* [gencommon] cleanup DefaultArguments, get rid of some code duplication

* [gencommon] cleanup DynamicFieldAccess

* [gencommon] clean up DynamicOperators (also make the actual filter only depend on common context)

* [gencommon] cleanup SwitchBreakSynf (also remove its gencommon context dependency, add a TODO that it's to be removed)

* [gencommon] get rid of gencommon context dependency for UnnecessaryCastsRemoval and UnreachableCodeEliminationSynf filters

* [gencommon] minor [skip ci]

* [gencommon] cleanup IntDivisionSynf and get rid of gencommon context for the actual filter

* [gencommon] remove InitFunction dependency on gencommon context

* [gencommon] cleanup ExpressionUnwrap a bit

* [gencommon] cleanup and decouple from gencommon context InterfaceProps and Normalize (also fix normalize checking strict_meta instead of metadata_entry)

* [gencommon] use info from Filters.mark_switch_break_loops and remove SwitchBreakSynf

* Replace abstracts names with native name if specified

* use ocamlfind (HaxeFoundation#6123)

* [gencommon] clean up TryCatchWrapper and lose gencommon context dependency in the actual filter code

* add a comment [skip ci]

* [gencommon] cleanup AbstractImplementationFix

* [gencommon] clean up ArrayDeclSynf, lose gencommon context dependency

* [gencommon] clean up ClassInstance, lose gencommon context dependency (also the gspecial_vars check, but it doesn't seem to be needed)

* [gencommon] minor

* [gencommon] get rid of redundant Option wrapping for filters results (if we don't change expr/type, then we might as well just return it as is)

+ a couple of very minor changes

* [gencommon] minor

* [gencommon] cleanup cast method generation a bit

* [gencommon] minor

* [CI] fixed haxe_ver parsing

* [Makefile] keep the CFLAGS declaration

Such that make wouldn't pickup any CFLAGS env var, which happens to be defined in launchpad.
We probably shouldn't even use CFLAGS, since our source is not C... Maybe MLFLAGS or something would be better.

* [CI] clean up

* [CI] ubuntu wily is not supported anymore

* [cs/java] use native arrays for dynamic function invokation (HaxeFoundation#6125)

* [gencommon] minor

* [gencommon] minor (lose gencommon ctx dependency from the ensure_local function)

* don't duplicate field hashing function

* [gencommon] generate nicer ternary for the exception "catchall" unwrapping

* [gencommon] clean up TryCatchWrapper configuration a bit

* minor [skip ci]

* make dec/enc/decode/encode naming in macro interpreter consistent

* have a generic make_throw in ExprBuilder

* use ExprBuilder some more

* [cs/java] throw target native argument exceptions in closure classes

* [cs/java] throw nice-ish target-specific exceptions for bad dynamic field access

* [cs/java] run TryCatchWrapper as a normal filter before analyzer and DCE - much cleaner output \o/ (also lose any gencommon dependency) (HaxeFoundation#6128)

* small cleanup for TryCatchWrapper

* [cs/java] make static constructrors protected

* [gencommon] lose gencommon context dependency for the most OverloadingConstructor filter code

* [gencommon] lose gencommon context dependency for DefaultArguments

* [gencommon] reset temp vars before creating a type param cast method

* [AppVeyor] use the new host of fdopen's opam32.tar.xz

fdopen/opam-repository-mingw#26

* [AppVeyor] make curl support redirect

* [cs/java] extract DefaultArguments from gencommon into PASS 1.5 filters (HaxeFoundation#6134)

* run SetHXGen in filters

* [cs/java] move DefaultArguments filter into pre-analyzer/dce stage

* get rid of gencommon dependency for the DefaultArguments filter

* [cs/java] remove InterfaceMetas filter since `Filters.add_meta_field` does exactly the same

* minor cleanup for Filters.add_meta_field: only create field once, add _HxMeta type to the end of the types list (it matters when generating multiple types per module like it's done in C#)

* fix minor typo in Type.getEnumConstructs [skip ci]

* [cs/java] carry over @:protected meta when copying constructor

* [cs] optimize Type.getEnumConstructs and mark some enum class fields as protected

* Don't require Bool to be an enum (closes HaxeFoundation#5804, closes HaxeFoundation#4120) (HaxeFoundation#6137)

* [cs] some cleanup and optimizations for Type methods

* [cs] more random Type optimizations

* [gencommon] cleanup InitFunction a bit

* [cs] only generate __hx_constructs when Type.getEnumConstructs is there

* [python] use native startswith/endswith in StringTools (closes HaxeFoundation#6138)

* some cleanup for EnumToClass2 in preparation for java support (and extracting from gencommon)

* [gencommon] reuse Type.mk_field in Gencommon.mk_class_field

* [cs] move InterfaceProps into post-dce type filters, lose any gencommon dependency

* added hl libuv support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform-cpp Everything related to CPP / C++
Projects
None yet
Development

No branches or pull requests

3 participants