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

Implement proper macro scope resolution for generator/for #53674

Merged
merged 1 commit into from
Mar 13, 2024
Merged

Conversation

Keno
Copy link
Member

@Keno Keno commented Mar 9, 2024

I'm not super familiar with this code, but it appears to me that these need to be treated as equivalent to implicit let blocks for the purposes of macro hygiene, so add appropriate logic to the macroexpander. Fixes #53673.

@Keno
Copy link
Member Author

Keno commented Mar 10, 2024

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Mar 11, 2024

@nanosoldier runtests(["SmartAsserts", "UncertainEvidence", "GeneralizedRouwenhorst", "ConvexFit", "UnbalancedOptimalTransport", "ProgressMeter", "JMcDM", "MathProgBase", "PseudoBooleanOptimization", "AddInit", "Bonobo", "CMAEvolutionStrategy", "MbedTLS", "Flamenco", "DistributedArrays", "MultivariateBases", "SemialgebraicSets", "GeometricTheoremProver", "ConstraintTrees", "PolynomialTestSystems", "AffineArithmetic", "SimplicialCubature", "PolynomialsMutableArithmetics", "IteratedIntegration", "StaticPolynomials", "CarlemanLinearization", "MixedSubdivisions", "JackPolynomials", "PolyhedralOmega", "SelfOrganizingMaps", "SubpixelRegistration", "SBML", "MathematicalSystems", "DataInterpolations", "Insolation", "LegendrePolynomials", "MadNLPKrylov", "SymEngine", "MultivariateMoments", "ImplicitPlots", "MadNLPPardiso", "MadNLPMumps", "HybridSystems", "ExaTron", "SymbolicWedderburn", "FMIImport", "BenchmarkProfiles", "SymPyCore", "TrustRegionMethods", "LineSearches", "SphericalHarmonicExpansions", "Experimenter", "NonsmoothOptim", "Knapsacks", "BundleMethod", "ParametricLP", "CutPruners", "LinearFractional", "ComplexOptInterface", "PiecewiseLinearOpt", "MultiwayNumberPartitioning", "vOptGeneric", "JuDGE", "PolyhedralRelaxations", "EfficientFrontier", "BirkhoffDecomposition", "CorrelatedEquilibria", "OperationsResearchModels", "DisjunctiveProgramming", "NonogramSolver", "GLPKMathProgInterface", "Fri", "SparseVariables", "SymPy", "MiniZinc", "MultiJuMP", "StatsDiscretizations", "SymPyPythonCall", "UnitJuMP", "Dualization", "MultiObjectiveAlgorithms", "NLopt", "GraphOptInterface", "OOESAlgorithm", "InfrastructureModels", "QuantumCircuitOpt", "FindMinimaxPolynomial", "MathProgIncidence", "PerfectPacking", "AmplNLWriter", "LightGraphsFlows", "StatusSwitchingQP", "MultistartOptimization", "MAiNGO", "CSDP", "Pavito", "Allocations", "GraphsFlows", "OSQP", "RobustFactorizations", "ParamPunPam", "ECOS", "Markets", "DAQP", "SeparableOptimization", "VarianceComponentModels", "PetroleumModels", "Convex", "SCS", "StandaloneIpopt", "SDPLR", "GuessworkQuantumSideInfo", "YasolSolver", "SecretSanta", "ApproximateVanishingIdeals", "ReverseMcCormick", "NLSProblems", "SchattenNorms", "PolyDAQP", "Vecchia", "BlockDecomposition", "ChooseOptimizer", "Hyperopt", "Sudoku", "GLPK", "Clp", "NOMAD", "Ipopt", "SymbolicLimits", "LatinSquares", "LoopTools", "ShiftedProximalOperators", "LovaszTheta", "HCIToolbox", "LikelihoodProfiler", "LightGraphsMatching", "GraphsMatching", "PoGO", "Chordal", "SimpleWorkflowRecipes", "StrategicGames", "LongestPaths", "ModelOrderReductionToolkit", "DiscreteFunctions", "OnlinePortfolioSelection", "Cbc", "RecoverPose", "SymbolicCodegen", "NEOSServer", "WaterModels", "PATHSolver", "BoxCoxTrans", "Basinhopping", "ProximalMethods", "GARCH", "TheCannon", "CompressedSensing", "NLPModelsIpopt", "ExactOptimalTransport", "SupportPoints", "BDisposal", "DecisionProgramming", "GasModels", "DataAssim", "PGLib", "FrankWolfe", "LRSLib", "ProximalOperators", "FaSTLMM", "EnergyModelsBase", "PowerModelsAnnex", "LeastSquaresOptim", "CALiPPSO", "PCCAPlus", "EnergyModelsRenewableProducers", "EnergyModelsGeography", "PWF", "PowerModelsSecurityConstrained", "EnergyModelsInvestments", "BranchAndBound", "PolyhedralCubature", "PowerModelsMCDC", "PowerModelsRestoration", "PowerModels", "ProgressiveHedging", "VoronoiGraph", "Powersense", "ProjectAssigner", "FlexPlan", "PowerModelsADA", "BioGraph", "PowerModelsACDC", "BaytesOptim", "RiskMeasures", "ScalingCollapse", "PSFModels", "RealTimeScheduling", "CameraModels", "OpSel", "RevealedPreferences", "SDDP", "PowerModelsStability", "QUnfold", "Miletus", "QuantumWalk", "CbaOPF", "LiftAndLearn", "BaytesSMC", "SCTransform", "QHull", "OPFSampler", "TimetableSolver", "BlackBoxOptimizationBenchmarking", "LPVSpectral", "GtkObservables", "HyperModularity", "HallThruster", "LiteHF", "CountTimeSeries", "RheaMetacycParser", "CDDLib", "Complementarity", "GittinsIndices", "ElectricFields", "ScoreDrivenModels", "EquivalentCircuits", "MixedLRMoE", "Algames", "RoundAndSwap", "PolynomialAmoebas", "CharFuncPricing", "PowerModelsDistribution", "PandaModels", "Survival", "CalibrationErrorsDistributions", "FBCModelTests", "GasPowerModels", "HCGeoTherm", "LRMoE", "ClimateMARGO", "CommonOPF", "TulipaEnergyModel", "SumOfSquares", "BenchmarkingEconomicEfficiency", "PowerModelsProtection", "BlankLocalizationCore", "SymmetryReduceBZ", "Baytes", "AnyMOD", "OptimizationNOMAD", "DataEnvelopmentAnalysis", "StateSpaceModels", "Equate", "OptimizationPolyalgorithms", "Anneal", "GaussianMixtureAlignment", "InvariantSets", "NetDecOPF", "PowerModelsITD", "SynthControl", "InteractiveFixedEffectModels", "sparseQFCA", "E4ST", "LinRegOutliers", "RadiationSpectra", "IsingSolvers", "QUBO", "QUBODrivers", "OPFLearn", "BasisMatrices", "RobustModels", "QuantEcon", "MetidaNLopt", "MetidaFreq", "MQLib", "Autologistic", "MIPVerify", "QuartetNetworkGoodnessFit", "Metida", "CompEcon", "EclipsingBinaryStars", "UncertaintyQuantification", "PsychometricsBazaarBase", "ParallelAnalysis", "DWaveNeal", "ArviZ", "ConstraintModels", "MarriageMarkets", "CBLS", "TaylorModels", "GeoStatsModels", "SetProg", "Flowstar", "SignalAnalysis", "TaylorInversion", "RitSpls", "FuzzyCRegression", "GeoStatsBase", "NExOS", "EulerLagrange", "ReducedComplexityModeling", "DerivableFunctionsBase", "KeplerTools", "ParameterSpacePartitions", "OrdinalMultinomialModels", "JordanForm", "ReversePropagation", "SphericalFunctions", "IterativeLQR", "RandomFeatures", "SparseSensors", "FractionalCalculus", "SimplePosetAlgorithms", "PolaronMobility", "HarmonicPowerModels", "Pathfinder", "CompressiveLearning", "Unfolding", "MaximumEntropyMomentClosures", "ValueAtRisk", "MPISphericalHarmonics", "MathML", "GeoEstimation", "Photometry", "NetworkHawkesProcesses", "KdotP", "SingleCellProjections", "MathOptSymbolicAD", "PhyloDiamond", "GMMParameterEstimation", "Korg", "MolecularGaussians", "Extremes", "EquationsSolver", "GeneralizedMonteCarlo", "DifferentiableCollisions", "QuantitativeMRI", "PowerPlots", "LowLevelParticleFilters", "DoloYAML", "ClosedLoopReachability", "BEASTDataPrep", "Dolo", "QuasiCopula", "ThresholdStability", "RealPolyhedralHomotopy", "SwitchOnSafety", "NextGP", "MixedModelsPermutations", "SocialSamplingTheory", "JosephsonCircuits", "TensND", "GeoStatsValidation", "MetidaBioeq", "GeoStats", "StellaratorOptimization", "GeoStatsSolvers", "DirectTrajectoryOptimization", "VMEC", "ApproxManifoldProducts", "AlgamesDriving", "SymbolicControlSystems", "BloqadeDormandPrince", "Mikrubi", "BellDiagonalQudits", "GeometricProblems", "PETLION", "Phonetics", "BaseModelica", "StatisticalRethinking", "StochasticDelayDiffEq", "GameTheory", "NeuronBuilder", "IndependentComponentAnalysis", "ParameterizedFunctions", "Simpsons", "LocalAnisotropies", "UnfoldSim", "PlasmoPlots", "FSimZoo", "Scheduling", "BloqadeWaveforms", "DistributedRelaxationTimes", "BloqadeKrylov", "MNPDynamics", "ONSAS", "Petri", "LongMemory", "NMRAnalysis", "ChargeTransport", "LiquidElectrolytes", "Yunir", "BaytesInference", "Qwind", "TrajectoryGamesBase", "PortfolioAnalytics", "SymplecticMapTools", "MultiscaleGraphSignalTransforms", "MicroTracker", "SemanticTrajectories", "EnergyCommunity", "Biofilm", "FSimPlots", "MathepiaModels", "RigorousInvariantMeasures", "NeuroAnalysis"])

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

SGTM. But can you add a test for for local x and for outer x forms also, to make sure those don't error here because of the varlist call.

@vtjnash vtjnash added compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros labels Mar 11, 2024
@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@Keno
Copy link
Member Author

Keno commented Mar 12, 2024

for local x

I don't think we allow this form

julia> function foo()
       for local x = 1:2
       end
ERROR: end
ParseError:
# Error @ REPL[1]:2:18
function foo()
for local x = 1:2
#                └ ── invalid iteration spec: expected one of `=` `in` or `∈`
Stacktrace:
 [1] top-level scope
   @ none:1

@Keno Keno closed this Mar 12, 2024
@Keno Keno reopened this Mar 12, 2024
I'm not super familiar with this code, but it appears to me that
these need to be treated as equivalent to implicit let blocks for
the purposes of macro hygiene, so add appropriate logic to the
macroexpander. Fixes #53673.
@Keno
Copy link
Member Author

Keno commented Mar 12, 2024

@nanosoldier runtests(["SmartAsserts", "AddInit", "Experimenter", "ProgressMeter", "FindMinimaxPolynomial", "DistributedArrays", "BenchmarkingEconomicEfficiency", "SignalAnalysis", "ThresholdStability", "Flowstar", "HarmonicPowerModels", "SwitchOnSafety", "PhyloDiamond", "MetidaBioeq", "PETLION", "NMRAnalysis", "BloqadeWaveforms", "MicroTracker", "EnergyCommunity", "SemanticTrajectories"])

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - no new issues were detected.
The full report is available.

@Keno Keno merged commit 9ae7eab into master Mar 13, 2024
8 checks passed
@Keno Keno deleted the kf/53673 branch March 13, 2024 07:31
Keno added a commit that referenced this pull request Mar 20, 2024
I'm not super familiar with this code, but it appears to me that these
need to be treated as equivalent to implicit let blocks for the purposes
of macro hygiene, so add appropriate logic to the macroexpander. Fixes
#53673.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:lowering Syntax lowering (compiler front end, 2nd stage) macros @macros
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect macro hygiene in comprehension lowering
3 participants