2
0
Эх сурвалжийг харах

Merge branch 'development' into constrained_monomorphs

# Conflicts:
#	src/core/type.ml
Simon Krajewski 6 жил өмнө
parent
commit
6b44cdc31b
49 өөрчлөгдсөн 319 нэмэгдсэн , 222 устгасан
  1. 3 0
      .gitignore
  2. 0 14
      .merlin
  3. 1 1
      .vscode/tasks.json
  4. 16 126
      Makefile
  5. 0 11
      Makefile.version_extra
  6. 1 0
      Makefile.win
  7. 1 0
      dune
  8. 10 0
      dune-project
  9. 2 0
      dune-workspace.dev
  10. 12 0
      extra/CHANGES.txt
  11. 0 2
      extra/azure-pipelines/build-linux.yml
  12. 0 2
      extra/azure-pipelines/build-mac.yml
  13. 0 1
      extra/azure-pipelines/build-windows.yml
  14. 16 0
      libs/extc/dune
  15. 7 0
      libs/extlib-leftovers/dune
  16. 8 0
      libs/ilib/dune
  17. 4 4
      libs/ilib/ilMetaWriter.ml
  18. 7 0
      libs/javalib/dune
  19. 6 0
      libs/json/dune
  20. 0 0
      libs/json/json.ml
  21. 7 0
      libs/neko/dune
  22. 9 0
      libs/objsize/dune
  23. 7 0
      libs/pcre/dune
  24. 8 0
      libs/swflib/dune
  25. 7 0
      libs/ttflib/dune
  26. 2 0
      libs/ttflib/main.ml
  27. 7 0
      libs/ziplib/dune
  28. 1 1
      src-json/define.json
  29. 8 0
      src-prebuild/dune
  30. 14 4
      src-prebuild/prebuild.ml
  31. 20 16
      src/codegen/gencommon/normalize.ml
  32. 0 0
      src/compiler/haxe.ml
  33. 11 0
      src/core/dune
  34. 1 1
      src/core/globals.ml
  35. 3 3
      src/core/type.ml
  36. 23 0
      src/dune
  37. 5 0
      src/syntax/dune
  38. 34 5
      src/typing/calls.ml
  39. 0 4
      std/UInt.hx
  40. 2 2
      std/haxe/display/Protocol.hx
  41. 13 0
      tests/misc/cs/projects/Issue6635/Main.hx
  42. 3 0
      tests/misc/cs/projects/Issue6635/compile.hxml
  43. 0 0
      tests/misc/cs/projects/Issue6635/compile.hxml.stderr
  44. 10 0
      tests/misc/cs/projects/Issue8589/Main.hx
  45. 3 0
      tests/misc/cs/projects/Issue8589/compile.hxml
  46. 0 0
      tests/misc/cs/projects/Issue8589/compile.hxml.stderr
  47. 0 24
      tests/unit/src/unit/issues/Issue6635.hx
  48. 19 0
      tests/unit/src/unit/issues/Issue6880.hx
  49. 8 1
      tests/unit/src/unit/issues/Issue8716.hx

+ 3 - 0
.gitignore

@@ -129,3 +129,6 @@ tests/display/.unittest/
 tests/unit/.unittest/
 tests/threads/export/
 tests/server/test.js.map
+*.merlin
+lib.sexp
+src/compiler/version.ml

+ 0 - 14
.merlin

@@ -1,14 +0,0 @@
-S src/**
-B _build/src/**
-S libs/**
-B libs/**
-B +threads
-PKG ptmap
-PKG sedlex
-PKG extlib
-PKG camlzip
-PKG xml-light
-PKG sha
-FLG -safe-string
-FLG -w -3
-FLG -w -40

+ 1 - 1
.vscode/tasks.json

@@ -1,5 +1,5 @@
 {
-    "version": "2.0.0",
+	"version": "2.0.0",
 	"tasks": [
 		{
 			"label": "make: haxe",

+ 16 - 126
Makefile

@@ -21,6 +21,7 @@ PACKAGE_SRC_EXTENSION=.tar.gz
 MAKEFILENAME?=Makefile
 PLATFORM?=unix
 
+DUNE_COMMAND=dune
 HAXE_OUTPUT=haxe
 HAXELIB_OUTPUT=haxelib
 PREBUILD_OUTPUT=prebuild
@@ -30,48 +31,6 @@ STATICLINK?=0
 
 # Configuration
 
-# Modules in these directories should only depend on modules that are in directories to the left
-HAXE_DIRECTORIES=core core/ds core/json core/display syntax context context/display codegen codegen/gencommon generators generators/jvm optimization filters macro macro/eval macro/eval/bytes typing compiler
-EXTLIB_LIBS=extlib-leftovers extc neko javalib swflib ttflib ilib objsize pcre ziplib
-OCAML_LIBS=unix str threads dynlink
-OPAM_LIBS=sedlex.ppx xml-light extlib ptmap sha
-
-FINDLIB_LIBS=$(OCAML_LIBS)
-FINDLIB_LIBS+=$(OPAM_LIBS)
-
-# Includes, packages and compiler
-
-HAXE_INCLUDES=$(HAXE_DIRECTORIES:%=-I _build/src/%)
-EXTLIB_INCLUDES=$(EXTLIB_LIBS:%=-I libs/%)
-ALL_INCLUDES=$(EXTLIB_INCLUDES) $(HAXE_INCLUDES)
-FINDLIB_PACKAGES=$(FINDLIB_LIBS:%=-package %)
-CFLAGS=
-ALL_CFLAGS=-bin-annot -safe-string -thread -g -w -3 -w -40 $(CFLAGS) $(ALL_INCLUDES) $(FINDLIB_PACKAGES)
-
-MESSAGE_FILTER=sed -e 's/_build\/src\//src\//' tmp.tmp
-
-ifeq ($(BYTECODE),1)
-	TARGET_FLAG = bytecode
-	COMPILER = ocamlfind ocamlc
-	LIB_EXT = cma
-	MODULE_EXT = cmo
-	NATIVE_LIB_FLAG = -custom
-else
-	TARGET_FLAG = native
-	COMPILER = ocamlfind ocamlopt
-	LIB_EXT = cmxa
-	MODULE_EXT = cmx
-	OCAMLDEP_FLAGS = -native
-endif
-
-CC_CMD = ($(COMPILER) $(ALL_CFLAGS) -c $< 2>tmp.tmp && $(MESSAGE_FILTER)) || ($(MESSAGE_FILTER) && exit 1)
-
-# Meta information
-
-BUILD_DIRECTORIES := $(HAXE_DIRECTORIES:%=_build/src/%)
-HAXE_SRC := $(wildcard $(HAXE_DIRECTORIES:%=src/%/*.ml))
-BUILD_SRC := $(HAXE_SRC:%=_build/%)
-
 ADD_REVISION?=0
 
 BRANCH=$(shell echo $$APPVEYOR_REPO_NAME | grep -q /haxe && echo $$APPVEYOR_REPO_BRANCH || echo $$TRAVIS_REPO_SLUG | grep -q /haxe && echo $$TRAVIS_BRANCH || git rev-parse --abbrev-ref HEAD)
@@ -87,94 +46,26 @@ PACKAGE_FILE_NAME=haxe_$(COMMIT_DATE)_$(COMMIT_SHA)
 HAXE_VERSION=$(shell $(CURDIR)/$(HAXE_OUTPUT) -version 2>&1 | awk '{print $$1;}')
 HAXE_VERSION_SHORT=$(shell echo "$(HAXE_VERSION)" | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+")
 
-# using $(CURDIR) on Windows will not work since it might be a Cygwin path
-ifdef SYSTEMROOT
-	EXTENSION=.exe
-else
-	export HAXE_STD_PATH=$(CURDIR)/std
-endif
-
-# Native libraries
-
 ifneq ($(STATICLINK),0)
 	LIB_PARAMS= -cclib '-Wl,-Bstatic -lpcre -lz -Wl,-Bdynamic '
 else
 	LIB_PARAMS?= -cclib -lpcre -cclib -lz
 endif
 
-NATIVE_LIBS=-thread -cclib libs/extc/extc_stubs.o -cclib libs/extc/process_stubs.o -cclib libs/objsize/c_objsize.o -cclib libs/pcre/pcre_stubs.o -ccopt -L/usr/local/lib $(LIB_PARAMS)
-
-# Modules
-
--include Makefile.modules
-
-# Rules
-
-all: libs haxe tools
-
-libs:
-	$(foreach lib,$(EXTLIB_LIBS),$(MAKE) -C libs/$(lib) $(TARGET_FLAG) &&) true
-
-_build/%:%
-	mkdir -p $(dir $@)
-	cp $< $@
-
-build_dirs:
-	@mkdir -p $(BUILD_DIRECTORIES)
-
-_build/src/syntax/grammar.ml:src/syntax/grammar.mly
-	camlp5o -impl $< -o $@
-
-_build/src/compiler/version.ml: FORCE
-ifneq ($(ADD_REVISION),0)
-	$(MAKE) -f Makefile.version_extra -s --no-print-directory ADD_REVISION=$(ADD_REVISION) BRANCH=$(BRANCH) COMMIT_SHA=$(COMMIT_SHA) COMMIT_DATE=$(COMMIT_DATE) > _build/src/compiler/version.ml
-else
-	echo let version_extra = None > _build/src/compiler/version.ml
-endif
-
-_build/src/core/defineList.ml: src-json/define.json prebuild
-	./$(PREBUILD_OUTPUT) define $< > $@
-
-_build/src/core/metaList.ml: src-json/meta.json prebuild
-	./$(PREBUILD_OUTPUT) meta $< > $@
-
-build_src: | $(BUILD_SRC) _build/src/syntax/grammar.ml _build/src/compiler/version.ml _build/src/core/defineList.ml _build/src/core/metaList.ml
-
-prebuild: _build/src/core/json/json.ml _build/src/prebuild/main.ml
-	$(COMPILER) -safe-string -linkpkg -g -o $(PREBUILD_OUTPUT) -package sedlex.ppx -package extlib -I _build/src/core/json _build/src/core/json/json.ml _build/src/prebuild/main.ml
+all: haxe tools
 
-haxe: build_src
-	$(MAKE) -f $(MAKEFILENAME) build_pass_1
-	$(MAKE) -f $(MAKEFILENAME) build_pass_2
-	$(MAKE) -f $(MAKEFILENAME) build_pass_3
-	$(MAKE) -f $(MAKEFILENAME) build_pass_4
-
-build_pass_1:
-	printf MODULES= > Makefile.modules
-	ls -1 $(HAXE_DIRECTORIES:%=_build/src/%/*.ml) | tr '\n' ' ' >> Makefile.modules
-
-build_pass_2:
-	printf MODULES= > Makefile.modules
-	ocamlfind ocamldep -sort -slash $(HAXE_INCLUDES) $(MODULES) | sed -e "s/\.ml//g" >> Makefile.modules
-
-build_pass_3:
-	ocamlfind ocamldep -slash $(OCAMLDEP_FLAGS) $(HAXE_INCLUDES) $(MODULES:%=%.ml) > Makefile.dependencies
-
-build_pass_4: $(MODULES:%=%.$(MODULE_EXT))
-	$(COMPILER) -safe-string -linkpkg -g -o $(HAXE_OUTPUT) $(NATIVE_LIBS) $(NATIVE_LIB_FLAG) $(LFLAGS) $(FINDLIB_PACKAGES) $(EXTLIB_INCLUDES) $(EXTLIB_LIBS:=.$(LIB_EXT)) $(MODULES:%=%.$(MODULE_EXT))
+haxe:
+	$(DUNE_COMMAND) build --workspace dune-workspace.dev src-prebuild/prebuild.exe
+	_build/default/src-prebuild/prebuild.exe libparams $(LIB_PARAMS) > lib.sexp
+	_build/default/src-prebuild/prebuild.exe version $(ADD_REVISION) $(BRANCH) $(COMMIT_SHA) > src/compiler/version.ml
+	$(DUNE_COMMAND) build --workspace dune-workspace.dev src/haxe.exe
+	cp -f _build/default/src/haxe.exe ./${HAXE_OUTPUT}
 
 kill_exe_win:
 ifdef SYSTEMROOT
 	-@taskkill /F /IM haxe.exe 2>/dev/null
 endif
 
-plugin:
-ifeq ($(BYTECODE),1)
-	$(CC_CMD) $(PLUGIN).ml
-else
-	$(COMPILER) $(ALL_CFLAGS) -shared -o $(PLUGIN).cmxs $(PLUGIN).ml
-endif
-
 # Only use if you have only changed gencpp.ml
 quickcpp: build_src build_pass_4 copy_haxetoolkit
 
@@ -211,14 +102,16 @@ uninstall:
 	rm -rf $(DESTDIR)$(INSTALL_STD_DIR)
 
 opam_install:
-	opam install $(OPAM_LIBS) camlp5 ocamlfind --yes
-
-# Dependencies
+	opam install camlp5 ocamlfind dune --yes
 
--include Makefile.dependencies
+haxe_deps:
+	opam pin add haxe . --no-action
+	opam install haxe --deps-only --yes
 
 # Package
 
+package_env: opam_install haxe_deps
+
 package_src:
 	mkdir -p $(PACKAGE_OUT_DIR)
 	# use git-archive-all since we have submodules
@@ -300,10 +193,7 @@ package_installer_mac: $(INSTALLER_TMP_DIR)/neko-osx64.tar.gz package_unix
 
 # Clean
 
-clean: clean_libs clean_haxe clean_tools clean_package
-
-clean_libs:
-	$(foreach lib,$(EXTLIB_LIBS),$(MAKE) -C libs/$(lib) clean &&) true
+clean: clean_haxe clean_tools clean_package
 
 clean_haxe:
 	rm -f -r _build $(HAXE_OUTPUT) $(PREBUILD_OUTPUT)
@@ -324,4 +214,4 @@ FORCE:
 .ml.cmo:
 	$(CC_CMD)
 
-.PHONY: haxe libs haxelib
+.PHONY: haxe haxelib

+ 0 - 11
Makefile.version_extra

@@ -1,11 +0,0 @@
-# A hack to print the content of version.ml consistently across Windows (cygwin / command prompt) and Unix.
-# The hack: http://stackoverflow.com/a/7284135/267998
-# The issue: https://github.com/HaxeFoundation/haxe/commit/4f8f6a99ddf810ea045492cdd6d40c55abc03e15#commitcomment-10660400
-
-all: ;
-
-ifneq ($(ADD_REVISION),0)
-	$(info let version_extra = Some ("git build $(BRANCH)","$(COMMIT_SHA)"))
-else
-	$(info let version_extra = None)
-endif

+ 1 - 0
Makefile.win

@@ -7,6 +7,7 @@ PREBUILD_OUTPUT=prebuild.exe
 EXTENSION=.exe
 PACKAGE_SRC_EXTENSION=.zip
 ARCH?=32
+DUNE_COMMAND=dune.exe
 
 ifeq ($(ARCH),64)
 NEKO_ARCH_STR=64

+ 1 - 0
dune

@@ -0,0 +1 @@
+(data_only_dirs extra lib std tests)

+ 10 - 0
dune-project

@@ -0,0 +1,10 @@
+(lang dune 1.11)
+(name haxe)
+
+(package
+	(name haxe)
+)
+
+(package
+	(name haxe_prebuild)
+)

+ 2 - 0
dune-workspace.dev

@@ -0,0 +1,2 @@
+(lang dune 1.11)
+(profile release)

+ 12 - 0
extra/CHANGES.txt

@@ -1,3 +1,15 @@
+2019-09-12: 4.0.0-rc.5
+
+	General improvements and optimizations:
+
+	eval: improved performance of regular expressions (#8693)
+
+	Bugfixes:
+
+	all: fixed regression, which caused compiler to crash on enum abstracts with explicit casting (#8765)
+	all: fixed regression of macro `@:from` methods on abstracts (#8779)
+	all: fixed switching on `this` (#8781)
+
 2019-09-04: 4.0.0-rc.4
 
 	Standard Library:

+ 0 - 2
extra/azure-pipelines/build-linux.yml

@@ -32,8 +32,6 @@ jobs:
         displayName: Install OCaml libraries
       - script: |
           set -ex
-          opam config exec -- make -s STATICLINK=1 libs
-          opam config exec -- make -s STATICLINK=1 prebuild
           opam config exec -- make -s -j`nproc` STATICLINK=1 haxe
           opam config exec -- make -s haxelib
           make -s package_bin

+ 0 - 2
extra/azure-pipelines/build-mac.yml

@@ -31,8 +31,6 @@ jobs:
         displayName: Install OCaml libraries
       - script: |
           set -ex
-          opam config exec -- make -s STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" libs
-          opam config exec -- make -s STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" prebuild
           opam config exec -- make -s -j`sysctl -n hw.ncpu` STATICLINK=1 "LIB_PARAMS=/usr/local/opt/zlib/lib/libz.a /usr/local/lib/libpcre.a" haxe
           opam config exec -- make -s haxelib
           make -s package_bin package_installer_mac

+ 0 - 1
extra/azure-pipelines/build-windows.yml

@@ -54,7 +54,6 @@ jobs:
         displayName: Expose mingw dll files
       - powershell: |
           Set-PSDebug -Trace 1
-          & "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win libs prebuild 2>&1')
           & "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win -j`nproc` haxe 2>&1')
           & "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -s -f Makefile.win haxelib 2>&1')
           & "$(CYG_ROOT)/bin/bash.exe" @('-lc', 'cd "$OLDPWD" && opam config exec -- make -f Makefile.win echo_package_files package_bin package_installer_win package_choco 2>&1')

+ 16 - 0
libs/extc/dune

@@ -0,0 +1,16 @@
+(include_subdirs no)
+
+(library
+	(name extc)
+	(libraries extlib)
+	(c_names extc_stubs)
+	(modules extc)
+	(wrapped false)
+)
+
+(library
+	(name extproc)
+	(c_names process_stubs)
+	(modules process)
+	(wrapped false)
+)

+ 7 - 0
libs/extlib-leftovers/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name extlib_leftovers)
+	(libraries extlib)
+	(wrapped false)
+)

+ 8 - 0
libs/ilib/dune

@@ -0,0 +1,8 @@
+(include_subdirs no)
+
+(library
+	(name ilib)
+	(modules_without_implementation ilData ilMeta)
+	(libraries extlib)
+	(wrapped false)
+)

+ 4 - 4
libs/ilib/ilMetaWriter.ml

@@ -68,11 +68,11 @@ let int_of_type_def_string = function
 
 let int_of_type_def_flags f =
 	int_of_type_def_vis f.tdf_vis
-		logor
+		lor
 	int_of_type_def_layout f.tdf_layout
-		logor
+		lor
 	int_of_type_def_semantics f.tdf_semantics
-		logor
+		lor
 	int_of_type_def_impl f.tdf_impl
-		logor
+		lor
 	int_of_type_def_string f.tdf_string

+ 7 - 0
libs/javalib/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name javalib)
+	(libraries extlib)
+	(wrapped false)
+)

+ 6 - 0
libs/json/dune

@@ -0,0 +1,6 @@
+(include_subdirs no)
+
+(library
+	(name json)
+	(preprocess (pps sedlex.ppx))
+)

+ 0 - 0
src/core/json/json.ml → libs/json/json.ml


+ 7 - 0
libs/neko/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name neko)
+	(libraries extlib)
+	(wrapped false)
+)

+ 9 - 0
libs/objsize/dune

@@ -0,0 +1,9 @@
+(include_subdirs no)
+
+(library
+	(name objsize)
+	(c_names c_objsize)
+	(c_flags (-I../../../../libs/objsize)) ; TODO: This is stupid
+	(wrapped false)
+	(modules objsize)
+)

+ 7 - 0
libs/pcre/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name pcre)
+	(c_names pcre_stubs)
+	(wrapped false)
+)

+ 8 - 0
libs/swflib/dune

@@ -0,0 +1,8 @@
+(include_subdirs no)
+
+(library
+	(name swflib)
+	(libraries extc extlib extlib_leftovers)
+	(modules_without_implementation as3 as3hl)
+	(wrapped false)
+)

+ 7 - 0
libs/ttflib/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name ttflib)
+	(libraries extlib extlib_leftovers swflib)
+	(wrapped false)
+)

+ 2 - 0
libs/ttflib/main.ml

@@ -65,6 +65,8 @@ let process args =
  				let config = {
  					ttfc_range_str = range_str;
  					ttfc_font_name = None;
+					ttfc_font_weight = TFWRegular;
+					ttfc_font_posture = TFPNormal;
  				} in
 				let f2 = TTFSwfWriter.to_swf ttf config in
 				let ch = IO.output_channel (open_out_bin (dir ^ "/" ^ ttf.ttf_font_name ^ ".dat")) in

+ 7 - 0
libs/ziplib/dune

@@ -0,0 +1,7 @@
+(include_subdirs no)
+
+(library
+	(name ziplib)
+	(libraries extc unix)
+	(wrapped false)
+)

+ 1 - 1
src-json/define.json

@@ -310,7 +310,7 @@
 	{
 		"name": "SourceMap",
 		"define": "source_map",
-		"doc": "Generate source map for compiled files. Note: for JavaScript prefer",
+		"doc": "Generate source map for compiled files.",
 		"platforms": ["php", "js"]
 	},
 	{

+ 8 - 0
src-prebuild/dune

@@ -0,0 +1,8 @@
+(include_subdirs no)
+
+(executable
+	(name prebuild)
+	(public_name haxe_prebuild)
+	(package haxe_prebuild)
+	(libraries extlib json)
+)

+ 14 - 4
src/prebuild/main.ml → src-prebuild/prebuild.ml

@@ -196,8 +196,8 @@ type meta_parameter =
 
 ;;
 
-match Sys.argv with
-	| [|_; "define"; define_path|] ->
+match Array.to_list (Sys.argv) with
+	| [_; "define"; define_path]->
 		let defines = parse_file_array define_path parse_define in
 		Printf.printf "%s" define_header;
 		Printf.printf "type strict_defined =\n";
@@ -206,7 +206,7 @@ match Sys.argv with
 		Printf.printf "let infos = function\n";
 		Printf.printf "%s" (gen_define_info defines);
 		Printf.printf "\n\t| Last -> assert false\n"
-	| [|_; "meta"; meta_path|] ->
+	| [_; "meta"; meta_path]->
 		let metas = parse_file_array meta_path parse_meta in
 		Printf.printf "%s" meta_header;
 		Printf.printf "type strict_meta =\n";
@@ -215,4 +215,14 @@ match Sys.argv with
 		Printf.printf "let get_info = function\n";
 		Printf.printf "%s" (gen_meta_info metas);
 		Printf.printf "\n\t| Last -> assert false\n\t| Dollar s -> \"$\" ^ s,(\"\",[])\n\t| Custom s -> s,(\"\",[])\n"
-	| _ -> ()
+	| _ :: "libparams" :: params ->
+		Printf.printf "(%s)" (String.concat " " (List.map (fun s -> Printf.sprintf "\"%s\"" s) params))
+	| [_ ;"version";add_revision;branch;sha] ->
+		begin match add_revision with
+		| "0" | "" ->
+			print_endline "let version_extra = None"
+		| _ ->
+			Printf.printf "let version_extra = Some (\"git build %s\",\"%s\")" branch sha
+		end
+	| args ->
+		print_endline (String.concat ", " args)

+ 20 - 16
src/codegen/gencommon/normalize.ml

@@ -29,41 +29,45 @@ open Gencommon
 		as it will help normalize the AST
 *)
 
-let rec filter_param t =
+let rec filter_param stack t =
 	match t with
 	| TInst({ cl_kind = KTypeParameter _ } as c,_) when Meta.has Meta.EnumConstructorParam c.cl_meta ->
 		t_dynamic
 	| TMono r ->
 		(match r.tm_type with
 		| None -> t_dynamic
-		| Some t -> filter_param t)
-	| TInst(_,[]) | TEnum(_,[]) | TType(_,[]) | TAbstract(_,[]) ->
+		| Some t -> filter_param stack t)
+	| TInst(_,[]) | TEnum(_,[]) | TAbstract(_,[]) ->
 		t
-	| TType(t,tl) ->
-		TType(t,List.map filter_param tl)
+	| TType(td,tl) when Meta.has Meta.Semantics td.t_meta || Meta.has Meta.Strict td.t_meta || List.memq t stack ->
+		TType(td,List.map (filter_param stack) tl)
+	| TType(td,tl) ->
+		filter_param (t :: stack) (apply_params td.t_params tl td.t_type)
 	| TInst(c,tl) ->
-		TInst(c,List.map filter_param tl)
+		TInst(c,List.map (filter_param stack) tl)
 	| TEnum(e,tl) ->
-		TEnum(e,List.map filter_param tl)
+		TEnum(e,List.map (filter_param stack) tl)
 	| TAbstract({ a_path = (["haxe";"extern"],"Rest") } as a,tl) ->
-		TAbstract(a, List.map filter_param tl)
+		TAbstract(a, List.map (filter_param stack) tl)
 	| TAbstract({a_path = [],"Null"} as a,[t]) ->
-		TAbstract(a,[filter_param t])
-	| TAbstract(a,tl) when (Meta.has Meta.MultiType a.a_meta) ->
-		filter_param (Abstract.get_underlying_type a tl)
+		TAbstract(a,[filter_param stack t])
+	| TAbstract(a,tl) when not (Meta.has Meta.CoreType a.a_meta) ->
+		filter_param stack (Abstract.get_underlying_type a tl)
 	| TAbstract(a,tl) ->
-		TAbstract(a, List.map filter_param tl)
+		TAbstract(a, List.map (filter_param stack) tl)
 	| TAnon a ->
 		TAnon {
-			a_fields = PMap.map (fun f -> { f with cf_type = filter_param f.cf_type }) a.a_fields;
-			a_status = a.a_status;
+			a_fields = PMap.map (fun f -> { f with cf_type = filter_param stack f.cf_type }) a.a_fields;
+			a_status = a.a_status
 		}
 	| TFun(args,ret) ->
-		TFun(List.map (fun (n,o,t) -> (n,o,filter_param t)) args, filter_param ret)
+		TFun(List.map (fun (n,o,t) -> (n,o,filter_param stack t)) args, filter_param stack ret)
 	| TDynamic _ ->
 		t
 	| TLazy f ->
-		filter_param (lazy_type f)
+		filter_param stack (lazy_type f)
+
+let filter_param t = filter_param [] t
 
 let init_expr_filter allowed_metas =
 	let rec run e =

+ 0 - 0
src/compiler/main.ml → src/compiler/haxe.ml


+ 11 - 0
src/core/dune

@@ -0,0 +1,11 @@
+(rule
+	(targets metaList.ml)
+	(deps ../../src-json/meta.json)
+	(action (with-stdout-to metaList.ml (run %{bin:haxe_prebuild} meta ../../src-json/meta.json)))
+)
+
+(rule
+	(targets defineList.ml)
+	(deps ../../src-json/define.json)
+	(action (with-stdout-to defineList.ml (run %{bin:haxe_prebuild} define ../../src-json/define.json)))
+)

+ 1 - 1
src/core/globals.ml

@@ -28,7 +28,7 @@ let version = 4000
 let version_major = version / 1000
 let version_minor = (version mod 1000) / 100
 let version_revision = (version mod 100)
-let version_pre = Some "rc.4"
+let version_pre = Some "rc.5"
 
 let macro_platform = ref Neko
 

+ 3 - 3
src/core/type.ml

@@ -836,12 +836,12 @@ let rec follow_without_null t =
 	match t with
 	| TMono r ->
 		(match r.tm_type with
-		| Some t -> follow t
+		| Some t -> follow_without_null t
 		| _ -> t)
 	| TLazy f ->
-		follow (lazy_type f)
+		follow_without_null (lazy_type f)
 	| TType (t,tl) ->
-		follow (apply_params t.t_params tl t.t_type)
+		follow_without_null (apply_params t.t_params tl t.t_type)
 	| _ -> t
 
 (** Assumes `follow` has already been applied *)

+ 23 - 0
src/dune

@@ -0,0 +1,23 @@
+(include_subdirs unqualified)
+
+(env
+	(_
+		(flags (:standard -w -3 -thread))
+	)
+)
+
+(executable
+	(name haxe)
+	(public_name haxe)
+	(package haxe)
+	(libraries
+		extc extproc extlib_leftovers ilib javalib neko objsize pcre swflib ttflib ziplib
+		json
+		unix str threads dynlink
+		xml-light extlib ptmap sha
+	)
+	(preprocess (per_module
+		((pps sedlex.ppx) json lexer)
+	))
+	(link_flags (:include ../lib.sexp))
+)

+ 5 - 0
src/syntax/dune

@@ -0,0 +1,5 @@
+(rule
+	(targets grammar.ml)
+	(deps grammar.mly)
+	(action (run %{bin:camlp5o} -impl grammar.mly -o %{targets}))
+)

+ 34 - 5
src/typing/calls.ml

@@ -119,11 +119,40 @@ let mk_array_set_call ctx (cf,tf,r,e1,e2o) c ebase p =
 			make_call ctx ef [ebase;e1;evalue] r p
 
 let call_to_string ctx ?(resume=false) e =
-	(* Ignore visibility of the toString field. *)
-	ctx.meta <- (Meta.PrivateAccess,[],e.epos) :: ctx.meta;
-	let acc = type_field (TypeFieldConfig.create resume) ctx e "toString" e.epos MCall in
-	ctx.meta <- List.tl ctx.meta;
-	!build_call_ref ctx acc [] (WithType.with_type ctx.t.tstring) e.epos
+	let gen_to_string e =
+		(* Ignore visibility of the toString field. *)
+		ctx.meta <- (Meta.PrivateAccess,[],e.epos) :: ctx.meta;
+		let acc = type_field (TypeFieldConfig.create resume) ctx e "toString" e.epos MCall in
+		ctx.meta <- List.tl ctx.meta;
+		!build_call_ref ctx acc [] (WithType.with_type ctx.t.tstring) e.epos
+	in
+	if ctx.com.config.pf_static && not (is_nullable e.etype) then
+		gen_to_string e
+	else begin (* generate `if(e == null) 'null' else e.toString()` *)
+		let rec needs_temp_var e =
+			match e.eexpr with
+			| TLocal _ | TTypeExpr _ | TConst _ -> false
+			| TField (e, _) | TParenthesis e -> needs_temp_var e
+			| _ -> true
+		in
+		let string_null = mk (TConst (TString "null")) ctx.t.tstring e.epos in
+		if needs_temp_var e then
+			let tmp = alloc_var VGenerated "tmp" e.etype e.epos in
+			let tmp_local = mk (TLocal tmp) tmp.v_type tmp.v_pos in
+			let check_null = mk (TBinop (OpEq, tmp_local, mk (TConst TNull) tmp.v_type tmp.v_pos)) ctx.t.tbool e.epos in
+			{
+				eexpr = TBlock([
+					mk (TVar (tmp, Some e)) tmp.v_type tmp.v_pos;
+					mk (TIf (check_null, string_null, Some (gen_to_string tmp_local))) ctx.t.tstring tmp.v_pos;
+
+				]);
+				etype = ctx.t.tstring;
+				epos = e.epos;
+			}
+		else
+			let check_null = mk (TBinop (OpEq, e, mk (TConst TNull) e.etype e.epos)) ctx.t.tbool e.epos in
+			mk (TIf (check_null, string_null, Some (gen_to_string e))) ctx.t.tstring e.epos
+	end
 
 let rec unify_call_args' ctx el args r callp inline force_inline =
 	let in_call_args = ctx.in_call_args in

+ 0 - 4
std/UInt.hx

@@ -299,11 +299,7 @@ abstract UInt(Int) from Int to Int {
 
 	// TODO: radix is just defined to deal with doc_gen issues
 	private inline function toString(?radix:Int):String {
-		#if static
 		return Std.string(toFloat());
-		#else
-		return Std.string(this == null ? null : toFloat());
-		#end
 	}
 
 	private inline function toInt():Int {

+ 2 - 2
std/haxe/display/Protocol.hx

@@ -50,8 +50,8 @@ typedef Version = {
 	final major:Int;
 	final minor:Int;
 	final patch:Int;
-	final pre:String;
-	final build:String;
+	final ?pre:String;
+	final ?build:String;
 }
 
 typedef InitializeResult = Response<{

+ 13 - 0
tests/misc/cs/projects/Issue6635/Main.hx

@@ -0,0 +1,13 @@
+abstract A<V>(String) {}
+
+typedef S = {a:A<Int>};
+
+class Main {
+	function new(s:S) {}
+
+	static function getS():S return null;
+
+	static function main() {
+		new Main(getS());
+	}
+}

+ 3 - 0
tests/misc/cs/projects/Issue6635/compile.hxml

@@ -0,0 +1,3 @@
+-main Main
+-cs bin
+-D no-compilation

+ 0 - 0
tests/misc/cs/projects/Issue6635/compile.hxml.stderr


+ 10 - 0
tests/misc/cs/projects/Issue8589/Main.hx

@@ -0,0 +1,10 @@
+import cs.system.collections.generic.List_1;
+
+typedef T = {id:String};
+
+class Main {
+	public static function main() {
+		var list:List_1<T> = new List_1();
+		list.ConvertAll((t:T) -> t.id);
+	}
+}

+ 3 - 0
tests/misc/cs/projects/Issue8589/compile.hxml

@@ -0,0 +1,3 @@
+-main Main
+-cs bin
+-D no-compilation

+ 0 - 0
tests/misc/cs/projects/Issue8589/compile.hxml.stderr


+ 0 - 24
tests/unit/src/unit/issues/Issue6635.hx

@@ -1,24 +0,0 @@
-package unit.issues;
-
-class Issue6635 extends Test
-{
-  public function test()
-  {
-    var t = Main.main();
-	noAssert();
-  }
-}
-
-@:keep private abstract A<V>(String) {}
-
-private typedef S = {a:A<Int>};
-
-@:keep private class Main {
-	function new(s:S) {}
-
-	static function getS():S return null;
-
-	public static function main() {
-		return new Main(getS());
-	}
-}

+ 19 - 0
tests/unit/src/unit/issues/Issue6880.hx

@@ -0,0 +1,19 @@
+package unit.issues;
+
+private enum abstract JsonTypeKind<T>(String) {
+	var TMono;
+}
+
+class Issue6880 extends unit.Test {
+	function test() {
+		var u:Null<AInt> = null;
+		eq('null', '$u');
+	}
+}
+
+private abstract AInt(Int) from Int {
+	public inline function toString() {
+		var result = this + 100;
+		return '$result';
+	}
+}

+ 8 - 1
tests/unit/src/unit/issues/Issue8716.hx

@@ -7,8 +7,15 @@ private enum abstract JsonTypeKind<T>(String) {
 class Issue8716 extends unit.Test {
 #if !static
 	function test() {
-		var u:UInt = null;
+		var u:AInt = null;
 		eq('null', '$u');
 	}
 #end
+}
+
+private abstract AInt(Int) from Int {
+	public inline function toString() {
+		var result = this + 100;
+		return '$result';
+	}
 }